From b11ca4c9f12efd9482afcc99223d7ed244178c8c Mon Sep 17 00:00:00 2001 From: Sandmeyer Date: Wed, 14 Jan 2026 02:25:44 +0800 Subject: [PATCH] feat: add serde support for ISO31662/3 - Implement Serialize/Deserialize for ISO3166-2 and ISO3166-3 - Improve code by cargo fmt - Fix clippy warning - Add serde round-trip tests to ensure correctness --- Cargo.toml | 20 +- src/bin/main.rs | 78 +- src/iso3166_2.rs | 46 +- src/iso3166_3.rs | 570 ++++------- src/lib.rs | 2213 ++++++++----------------------------------- tests/test_serde.rs | 151 +++ 6 files changed, 839 insertions(+), 2239 deletions(-) create mode 100644 tests/test_serde.rs diff --git a/Cargo.toml b/Cargo.toml index d012a47..c7e4632 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,19 +2,31 @@ name = "rust_iso3166" version = "0.1.14" edition = "2021" -description="ISO 3166-1 (Codes for the representation of names of countries and their subdivisions – Part 1: Country codes) is a standard defining codes for the names of countries, dependent territories, and special areas of geographical interest. It is the first part of the ISO 3166 standard published by the International Organization for Standardization." -repository="https://github.com/rust-iso/rust_iso3166" -license="Apache-2.0" +description = "ISO 3166-1 (Codes for the representation of names of countries and their subdivisions – Part 1: Country codes) is a standard defining codes for the names of countries, dependent territories, and special areas of geographical interest. It is the first part of the ISO 3166 standard published by the International Organization for Standardization." +repository = "https://github.com/rust-iso/rust_iso3166" +license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html exclude = ["src/*.py"] documentation = "https://docs.rs/rust_iso3166/" -keywords=["ISO3166", "ISO3166-1", "ISO3166-2", "ISO3166-3"] +keywords = ["ISO3166", "ISO3166-1", "ISO3166-2", "ISO3166-3"] [lib] crate-type = ["cdylib", "rlib"] +[features] +default = [] +serde = ["dep:serde"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(direct_wasm)'] } + + [dependencies] phf = { version = "^0.11.1", features = ["macros"] } +serde = { version = "^1.0.228", optional = true } + +[dev-dependencies] +serde_json = { version = "^1.0.107" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] prettytable-rs = "^0.10" diff --git a/src/bin/main.rs b/src/bin/main.rs index a3ca6a9..86fc631 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -1,55 +1,49 @@ #[cfg(not(target_arch = "wasm32"))] fn main() { - use prettytable::{row, Table}; - use std::env; + use prettytable::{row, Table}; + use std::env; - let mut args = env::args(); - let script_name = match args.next() { - Some(arg) => arg, - None => String::from(""), - }; - let query = match args.next() { - Some(arg) => arg, - None => String::from(""), - }; - let query = &query.to_lowercase(); + let mut args = env::args(); + let script_name = args.next().unwrap_or_default(); + let query = args.next().unwrap_or_default(); + let query = &query.to_lowercase(); - eprintln!("Usage: {} [query]", script_name); - let mut found = false; - let mut table = Table::new(); - table.add_row(row!["Name", "Alpha2", "Alpha3", "Numeric"]); + eprintln!("Usage: {} [query]", script_name); + let mut found = false; + let mut table = Table::new(); + table.add_row(row!["Name", "Alpha2", "Alpha3", "Numeric"]); - for country in rust_iso3166::ALL { - if country.alpha2.to_lowercase().contains(query) - || country.alpha3.to_lowercase().contains(query) - || country.numeric_str().to_lowercase().contains(query) - { - table.add_row(row![ - country.name, - country.alpha2, - country.alpha3, - country.numeric_str() - ]); - found = true; + for country in rust_iso3166::ALL { + if country.alpha2.to_lowercase().contains(query) + || country.alpha3.to_lowercase().contains(query) + || country.numeric_str().to_lowercase().contains(query) + { + table.add_row(row![ + country.name, + country.alpha2, + country.alpha3, + country.numeric_str() + ]); + found = true; + } } - } - if !found { - for country in rust_iso3166::ALL { - if country.name.to_lowercase().contains(query) { - table.add_row(row![ - country.name, - country.alpha2, - country.alpha3, - country.numeric_str() - ]); - } + if !found { + for country in rust_iso3166::ALL { + if country.name.to_lowercase().contains(query) { + table.add_row(row![ + country.name, + country.alpha2, + country.alpha3, + country.numeric_str() + ]); + } + } } - } - table.printstd(); + table.printstd(); } #[cfg(target_arch = "wasm32")] fn main() { - unimplemented!(); + unimplemented!(); } diff --git a/src/iso3166_2.rs b/src/iso3166_2.rs index 38c36e0..39be18e 100644 --- a/src/iso3166_2.rs +++ b/src/iso3166_2.rs @@ -1,7 +1,8 @@ - use phf::phf_map; use phf::Map; -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(feature = "serde")] +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +#[cfg(all(direct_wasm, target_arch = "wasm32"))] use wasm_bindgen::prelude::*; /// # Sample code @@ -11,12 +12,12 @@ use wasm_bindgen::prelude::*; /// assert!(subdivisions.unwrap().len() > 0); /// let country = rust_iso3166::iso3166_2::from_code("GB-EDH"); /// assert_eq!("Edinburgh, City of", country.unwrap().name); -/// println!("{:?}", rust_iso3166::iso3166_2::SUBDIVISION_COUNTRY_MAP); -/// println!("{:?}", rust_iso3166::iso3166_2::SUBDIVISION_MAP); +/// println!("{:?}", rust_iso3166::iso3166_2::SUBDIVISION_COUNTRY_MAP); +/// println!("{:?}", rust_iso3166::iso3166_2::SUBDIVISION_MAP); /// ``` /// Data for each Country Code defined by ISO 3166-2 -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct Subdivision { @@ -34,7 +35,7 @@ pub struct Subdivision { region_code: &'static str, } -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen] impl Subdivision { #[wasm_bindgen(getter)] @@ -68,7 +69,7 @@ impl Subdivision { } } -#[cfg(any(not(direct_wasm),not(target_arch = "wasm32")))] +#[cfg(any(not(direct_wasm), not(target_arch = "wasm32")))] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct Subdivision { ///Name @@ -96,6 +97,30 @@ pub fn from_code(code: &str) -> Option { SUBDIVISION_MAP.get(code).cloned() } +#[cfg(feature = "serde")] +impl Serialize for Subdivision { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(self.code) + } +} + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for Subdivision { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + use serde::de::Error; + let s = String::deserialize(deserializer)?; + let s_upper = s.to_uppercase(); + from_code(&s_upper) + .ok_or_else(|| D::Error::custom(format!("Invalid ISO 3166-2 code: {}", s))) + } +} + pub const AF_BAL: Subdivision = Subdivision { name: "Balkh", code: "AF-BAL", @@ -46140,8 +46165,7 @@ pub const ZW_MW: Subdivision = Subdivision { region_code: "MW", }; - -///Subdivision map with Code key +///Subdivision map with Code key pub const SUBDIVISION_MAP: Map<&str, Subdivision> = phf_map! { "AF-BAL" => AF_BAL, @@ -51263,8 +51287,7 @@ pub const SUBDIVISION_MAP: Map<&str, Subdivision> = phf_map! { }; - -///Subdivision map with Code key +///Subdivision map with Code key pub const SUBDIVISION_COUNTRY_MAP: Map<&str, &[Subdivision]> = phf_map! { "AF" => &[ @@ -56885,4 +56908,3 @@ ZW_MW, ], }; - diff --git a/src/iso3166_3.rs b/src/iso3166_3.rs index 006f258..2ff5215 100644 --- a/src/iso3166_3.rs +++ b/src/iso3166_3.rs @@ -1,14 +1,15 @@ - +use crate::CountryCode; +#[cfg(all(direct_wasm, target_arch = "wasm32"))] +use js_sys::Array; use phf::phf_map; use phf::Map; -use crate::CountryCode; -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(feature = "serde")] +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +#[cfg(all(direct_wasm, target_arch = "wasm32"))] use wasm_bindgen::prelude::*; -#[cfg(all(direct_wasm,target_arch = "wasm32"))] -use js_sys::Array; /// Data for each Country Code defined by ISO 3166-1 -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct CountryCode3 { @@ -24,10 +25,9 @@ pub struct CountryCode3 { validity: &'static [i32], ///Decription desc: &'static str, - } -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen] impl CountryCode3 { #[wasm_bindgen(getter)] @@ -47,21 +47,21 @@ impl CountryCode3 { #[wasm_bindgen(getter)] pub fn new_countries(&self) -> Array { - let mut vector: Vec = Vec::new(); + let mut vector: Vec = Vec::new(); // self.individual_languages.into_serde().unwrap(); - for i in 0..self.new_countries.len() { - vector.push(self.new_countries[i]) - } - vector.into_iter().map(JsValue::from).collect() + for i in 0..self.new_countries.len() { + vector.push(self.new_countries[i]) + } + vector.into_iter().map(JsValue::from).collect() } - + #[wasm_bindgen(getter)] pub fn desc(&self) -> String { self.desc.into() } } -#[cfg(any(not(direct_wasm),not(target_arch = "wasm32")))] +#[cfg(any(not(direct_wasm), not(target_arch = "wasm32")))] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct CountryCode3 { ///ISO 3166-3 code @@ -76,10 +76,8 @@ pub struct CountryCode3 { pub validity: &'static [i32], ///Decription pub desc: &'static str, - } - pub const BQAQ: CountryCode3 = CountryCode3 { code: "BQAQ", name: "British Antarctic Territory", @@ -89,21 +87,16 @@ pub const BQAQ: CountryCode3 = CountryCode3 { alpha3: "ATB", numeric: 0, }, - validity: &[1974,1979], + validity: &[1974, 1979], desc: "Merged into Antarctica ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Antarctica", alpha2: "AQ", alpha3: "ATA", numeric: 10, -}, - - ], + }], }; - pub const BUMM: CountryCode3 = CountryCode3 { code: "BUMM", name: "Burma", @@ -113,21 +106,16 @@ pub const BUMM: CountryCode3 = CountryCode3 { alpha3: "BUR", numeric: 104, }, - validity: &[1974,1989], + validity: &[1974, 1989], desc: "Name changed to Myanmar ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Myanmar", alpha2: "MM", alpha3: "MMR", numeric: 104, -}, - - ], + }], }; - pub const BYAA: CountryCode3 = CountryCode3 { code: "BYAA", name: "Byelorussian SSR", @@ -137,21 +125,16 @@ pub const BYAA: CountryCode3 = CountryCode3 { alpha3: "BYS", numeric: 112, }, - validity: &[1974,1992], + validity: &[1974, 1992], desc: "Name changed to Belarus ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Belarus", alpha2: "BY", alpha3: "BLR", numeric: 112, -}, - - ], + }], }; - pub const CTKI: CountryCode3 = CountryCode3 { code: "CTKI", name: "Canton and Enderbury Islands", @@ -161,21 +144,16 @@ pub const CTKI: CountryCode3 = CountryCode3 { alpha3: "CTE", numeric: 128, }, - validity: &[1974,1984], + validity: &[1974, 1984], desc: "Merged into Kiribati ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Kiribati", alpha2: "KI", alpha3: "KIR", numeric: 296, -}, - - ], + }], }; - pub const CSHH: CountryCode3 = CountryCode3 { code: "CSHH", name: "Czechoslovakia", @@ -185,27 +163,24 @@ pub const CSHH: CountryCode3 = CountryCode3 { alpha3: "CSK", numeric: 200, }, - validity: &[1974,1993], + validity: &[1974, 1993], desc: "Divided into: Czechia Slovakia ", new_countries: &[ - - CountryCode { - name: "Czechia", - alpha2: "CZ", - alpha3: "CZE", - numeric: 203, -}, - CountryCode { - name: "Slovakia", - alpha2: "SK", - alpha3: "SVK", - numeric: 703, -}, - + CountryCode { + name: "Czechia", + alpha2: "CZ", + alpha3: "CZE", + numeric: 203, + }, + CountryCode { + name: "Slovakia", + alpha2: "SK", + alpha3: "SVK", + numeric: 703, + }, ], }; - pub const DYBJ: CountryCode3 = CountryCode3 { code: "DYBJ", name: "Dahomey", @@ -215,21 +190,16 @@ pub const DYBJ: CountryCode3 = CountryCode3 { alpha3: "DHY", numeric: 204, }, - validity: &[1974,1977], + validity: &[1974, 1977], desc: "Name changed to Benin ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Benin", alpha2: "BJ", alpha3: "BEN", numeric: 204, -}, - - ], + }], }; - pub const NQAQ: CountryCode3 = CountryCode3 { code: "NQAQ", name: "Dronning Maud Land", @@ -239,21 +209,16 @@ pub const NQAQ: CountryCode3 = CountryCode3 { alpha3: "ATN", numeric: 216, }, - validity: &[1974,1983], + validity: &[1974, 1983], desc: "Merged into Antarctica ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Antarctica", alpha2: "AQ", alpha3: "ATA", numeric: 10, -}, - - ], + }], }; - pub const TPTL: CountryCode3 = CountryCode3 { code: "TPTL", name: "East Timor", @@ -263,21 +228,16 @@ pub const TPTL: CountryCode3 = CountryCode3 { alpha3: "TMP", numeric: 626, }, - validity: &[1974,2002], + validity: &[1974, 2002], desc: "Name changed to Timor-Leste ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Timor-Leste", alpha2: "TL", alpha3: "TLS", numeric: 626, -}, - - ], + }], }; - pub const FXFR: CountryCode3 = CountryCode3 { code: "FXFR", name: "France, Metropolitan", @@ -287,21 +247,16 @@ pub const FXFR: CountryCode3 = CountryCode3 { alpha3: "FXX", numeric: 249, }, - validity: &[1993,1997], + validity: &[1993, 1997], desc: "Merged into France ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "France", alpha2: "FR", alpha3: "FRA", numeric: 250, -}, - - ], + }], }; - pub const AIDJ: CountryCode3 = CountryCode3 { code: "AIDJ", name: "French Afars and Issas", @@ -311,21 +266,16 @@ pub const AIDJ: CountryCode3 = CountryCode3 { alpha3: "AFI", numeric: 262, }, - validity: &[1974,1977], + validity: &[1974, 1977], desc: "Name changed to Djibouti ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Djibouti", alpha2: "DJ", alpha3: "DJI", numeric: 262, -}, - - ], + }], }; - pub const FQHH: CountryCode3 = CountryCode3 { code: "FQHH", name: "French Southern and Antarctic Territories", @@ -335,27 +285,24 @@ pub const FQHH: CountryCode3 = CountryCode3 { alpha3: "ATF", numeric: 0, }, - validity: &[1974,1979], + validity: &[1974, 1979], desc: "Divided into: Part of Antarctica French Southern Territories ", new_countries: &[ - - CountryCode { - name: "Part of Antarctica", - alpha2: "AQ", - alpha3: "ATA", - numeric: 10, -}, - CountryCode { - name: "French Southern Territories", - alpha2: "TF", - alpha3: "ATF", - numeric: 260, -}, - + CountryCode { + name: "Part of Antarctica", + alpha2: "AQ", + alpha3: "ATA", + numeric: 10, + }, + CountryCode { + name: "French Southern Territories", + alpha2: "TF", + alpha3: "ATF", + numeric: 260, + }, ], }; - pub const DDDE: CountryCode3 = CountryCode3 { code: "DDDE", name: "German Democratic Republic", @@ -365,21 +312,16 @@ pub const DDDE: CountryCode3 = CountryCode3 { alpha3: "DDR", numeric: 278, }, - validity: &[1974,1990], + validity: &[1974, 1990], desc: "Merged into Germany ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Germany", alpha2: "DE", alpha3: "DEU", numeric: 276, -}, - - ], + }], }; - pub const GEHH: CountryCode3 = CountryCode3 { code: "GEHH", name: "Gilbert Islands", @@ -389,21 +331,16 @@ pub const GEHH: CountryCode3 = CountryCode3 { alpha3: "GEL", numeric: 296, }, - validity: &[1974,1979], + validity: &[1974, 1979], desc: "Name changed to Kiribati ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Kiribati", alpha2: "KI", alpha3: "KIR", numeric: 296, -}, - - ], + }], }; - pub const JTUM: CountryCode3 = CountryCode3 { code: "JTUM", name: "Johnston Island", @@ -413,21 +350,16 @@ pub const JTUM: CountryCode3 = CountryCode3 { alpha3: "JTN", numeric: 396, }, - validity: &[1974,1986], + validity: &[1974, 1986], desc: "Merged into United States Minor Outlying Islands ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "United States Minor Outlying Islands", alpha2: "UM", alpha3: "UMI", numeric: 581, -}, - - ], + }], }; - pub const MIUM: CountryCode3 = CountryCode3 { code: "MIUM", name: "Midway Islands", @@ -437,21 +369,16 @@ pub const MIUM: CountryCode3 = CountryCode3 { alpha3: "MID", numeric: 488, }, - validity: &[1974,1986], + validity: &[1974, 1986], desc: "Merged into United States Minor Outlying Islands ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "United States Minor Outlying Islands", alpha2: "UM", alpha3: "UMI", numeric: 581, -}, - - ], + }], }; - pub const ANHH: CountryCode3 = CountryCode3 { code: "ANHH", name: "Netherlands Antilles", @@ -461,33 +388,30 @@ pub const ANHH: CountryCode3 = CountryCode3 { alpha3: "ANT", numeric: 530, }, - validity: &[1974,2010 ], + validity: &[1974, 2010], desc: "Divided into: Bonaire, Sint Eustatius and Saba Curaçao Sint Maarten ", new_countries: &[ - - CountryCode { - name: "Bonaire, Sint Eustatius and Saba", - alpha2: "BQ", - alpha3: "BES", - numeric: 535, -}, - CountryCode { - name: "Curaçao", - alpha2: "CW", - alpha3: "CUW", - numeric: 531, -}, - CountryCode { - name: "Sint Maarten (Dutch part)", - alpha2: "SX", - alpha3: "SXM", - numeric: 534, -}, - + CountryCode { + name: "Bonaire, Sint Eustatius and Saba", + alpha2: "BQ", + alpha3: "BES", + numeric: 535, + }, + CountryCode { + name: "Curaçao", + alpha2: "CW", + alpha3: "CUW", + numeric: 531, + }, + CountryCode { + name: "Sint Maarten (Dutch part)", + alpha2: "SX", + alpha3: "SXM", + numeric: 534, + }, ], }; - pub const NTHH: CountryCode3 = CountryCode3 { code: "NTHH", name: "Neutral Zone", @@ -497,27 +421,24 @@ pub const NTHH: CountryCode3 = CountryCode3 { alpha3: "NTZ", numeric: 536, }, - validity: &[1974,1993], + validity: &[1974, 1993], desc: "Divided into: Part of Iraq Part of Saudi Arabia ", new_countries: &[ - - CountryCode { - name: "Part of Iraq", - alpha2: "IQ", - alpha3: "IRQ", - numeric: 368, -}, - CountryCode { - name: "Part of Saudi Arabia", - alpha2: "SA", - alpha3: "SAU", - numeric: 682, -}, - + CountryCode { + name: "Part of Iraq", + alpha2: "IQ", + alpha3: "IRQ", + numeric: 368, + }, + CountryCode { + name: "Part of Saudi Arabia", + alpha2: "SA", + alpha3: "SAU", + numeric: 682, + }, ], }; - pub const NHVU: CountryCode3 = CountryCode3 { code: "NHVU", name: "New Hebrides", @@ -527,21 +448,16 @@ pub const NHVU: CountryCode3 = CountryCode3 { alpha3: "NHB", numeric: 548, }, - validity: &[1974,1980], + validity: &[1974, 1980], desc: "Name changed to Vanuatu ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Vanuatu", alpha2: "VU", alpha3: "VUT", numeric: 548, -}, - - ], + }], }; - pub const PCHH: CountryCode3 = CountryCode3 { code: "PCHH", name: "Pacific Islands (Trust Territory)", @@ -551,39 +467,36 @@ pub const PCHH: CountryCode3 = CountryCode3 { alpha3: "PCI", numeric: 582, }, - validity: &[1974,1986], + validity: &[1974, 1986], desc: "Divided into: Marshall Islands Micronesia Northern Mariana Islands Palau ", new_countries: &[ - - CountryCode { - name: "Marshall Islands", - alpha2: "MH", - alpha3: "MHL", - numeric: 584, -}, - CountryCode { - name: "Micronesia (Federated States of)", - alpha2: "FM", - alpha3: "FSM", - numeric: 583, -}, - CountryCode { - name: "Northern Mariana Islands", - alpha2: "MP", - alpha3: "MNP", - numeric: 580, -}, - CountryCode { - name: "Palau", - alpha2: "PW", - alpha3: "PLW", - numeric: 585, -}, - + CountryCode { + name: "Marshall Islands", + alpha2: "MH", + alpha3: "MHL", + numeric: 584, + }, + CountryCode { + name: "Micronesia (Federated States of)", + alpha2: "FM", + alpha3: "FSM", + numeric: 583, + }, + CountryCode { + name: "Northern Mariana Islands", + alpha2: "MP", + alpha3: "MNP", + numeric: 580, + }, + CountryCode { + name: "Palau", + alpha2: "PW", + alpha3: "PLW", + numeric: 585, + }, ], }; - pub const PZPA: CountryCode3 = CountryCode3 { code: "PZPA", name: "Panama Canal Zone", @@ -593,21 +506,16 @@ pub const PZPA: CountryCode3 = CountryCode3 { alpha3: "PCZ", numeric: 0, }, - validity: &[1974,1980], + validity: &[1974, 1980], desc: "Merged into Panama ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Panama", alpha2: "PA", alpha3: "PAN", numeric: 591, -}, - - ], + }], }; - pub const CSXX: CountryCode3 = CountryCode3 { code: "CSXX", name: "Serbia and Montenegro", @@ -617,27 +525,24 @@ pub const CSXX: CountryCode3 = CountryCode3 { alpha3: "SCG", numeric: 891, }, - validity: &[2003,2006], + validity: &[2003, 2006], desc: "Divided into: Montenegro Serbia ", new_countries: &[ - - CountryCode { - name: "Montenegro", - alpha2: "ME", - alpha3: "MNE", - numeric: 499, -}, - CountryCode { - name: "Serbia", - alpha2: "RS", - alpha3: "SRB", - numeric: 688, -}, - + CountryCode { + name: "Montenegro", + alpha2: "ME", + alpha3: "MNE", + numeric: 499, + }, + CountryCode { + name: "Serbia", + alpha2: "RS", + alpha3: "SRB", + numeric: 688, + }, ], }; - pub const SKIN: CountryCode3 = CountryCode3 { code: "SKIN", name: "Sikkim", @@ -647,21 +552,16 @@ pub const SKIN: CountryCode3 = CountryCode3 { alpha3: "SKM", numeric: 0, }, - validity: &[1974,1975], + validity: &[1974, 1975], desc: "Merged into India ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "India", alpha2: "IN", alpha3: "IND", numeric: 356, -}, - - ], + }], }; - pub const RHZW: CountryCode3 = CountryCode3 { code: "RHZW", name: "Southern Rhodesia", @@ -671,21 +571,16 @@ pub const RHZW: CountryCode3 = CountryCode3 { alpha3: "RHO", numeric: 716, }, - validity: &[1974,1980], + validity: &[1974, 1980], desc: "Name changed to Zimbabwe ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Zimbabwe", alpha2: "ZW", alpha3: "ZWE", numeric: 716, -}, - - ], + }], }; - pub const PUUM: CountryCode3 = CountryCode3 { code: "PUUM", name: "United States Miscellaneous Pacific Islands", @@ -695,21 +590,16 @@ pub const PUUM: CountryCode3 = CountryCode3 { alpha3: "PUS", numeric: 849, }, - validity: &[1974,1986], + validity: &[1974, 1986], desc: "Merged into United States Minor Outlying Islands ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "United States Minor Outlying Islands", alpha2: "UM", alpha3: "UMI", numeric: 581, -}, - - ], + }], }; - pub const HVBF: CountryCode3 = CountryCode3 { code: "HVBF", name: "Upper Volta", @@ -719,21 +609,16 @@ pub const HVBF: CountryCode3 = CountryCode3 { alpha3: "HVO", numeric: 854, }, - validity: &[1974,1984], + validity: &[1974, 1984], desc: "Name changed to Burkina Faso ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Burkina Faso", alpha2: "BF", alpha3: "BFA", numeric: 854, -}, - - ], + }], }; - pub const SUHH: CountryCode3 = CountryCode3 { code: "SUHH", name: "USSR", @@ -829,7 +714,6 @@ pub const SUHH: CountryCode3 = CountryCode3 { ], }; - pub const VDVN: CountryCode3 = CountryCode3 { code: "VDVN", name: "Viet-Nam, Democratic Republic of", @@ -839,21 +723,16 @@ pub const VDVN: CountryCode3 = CountryCode3 { alpha3: "VDR", numeric: 0, }, - validity: &[1974,1977], + validity: &[1974, 1977], desc: "Merged into Viet Nam ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Viet Nam", alpha2: "VN", alpha3: "VNM", numeric: 704, -}, - - ], + }], }; - pub const WKUM: CountryCode3 = CountryCode3 { code: "WKUM", name: "Wake Island", @@ -863,21 +742,16 @@ pub const WKUM: CountryCode3 = CountryCode3 { alpha3: "WAK", numeric: 872, }, - validity: &[1974,1986], + validity: &[1974, 1986], desc: "Merged into United States Minor Outlying Islands ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "United States Minor Outlying Islands", alpha2: "UM", alpha3: "UMI", numeric: 581, -}, - - ], + }], }; - pub const YDYE: CountryCode3 = CountryCode3 { code: "YDYE", name: "Yemen, Democratic", @@ -887,21 +761,16 @@ pub const YDYE: CountryCode3 = CountryCode3 { alpha3: "YMD", numeric: 720, }, - validity: &[1974,1990], + validity: &[1974, 1990], desc: "Merged into Yemen ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Yemen", alpha2: "YE", alpha3: "YEM", numeric: 887, -}, - - ], + }], }; - pub const YUCS: CountryCode3 = CountryCode3 { code: "YUCS", name: "Yugoslavia", @@ -911,21 +780,16 @@ pub const YUCS: CountryCode3 = CountryCode3 { alpha3: "YUG", numeric: 891, }, - validity: &[1974,2003], + validity: &[1974, 2003], desc: "Name changed to Serbia and Montenegro ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Serbia and Montenegro", alpha2: "CS", alpha3: "SCG", numeric: 891, -}, - - ], + }], }; - pub const ZRCD: CountryCode3 = CountryCode3 { code: "ZRCD", name: "Zaire", @@ -935,21 +799,16 @@ pub const ZRCD: CountryCode3 = CountryCode3 { alpha3: "ZAR", numeric: 180, }, - validity: &[1974,1997], + validity: &[1974, 1997], desc: "Name changed to Congo, Democratic Republic of the ", - new_countries: &[ - - CountryCode { + new_countries: &[CountryCode { name: "Congo, Democratic Republic of the", alpha2: "CD", alpha3: "COD", numeric: 180, -}, - - ], + }], }; - /// Returns the CountryCode3 with the given Alpha4 code, if exists. /// #Sample /// ``` @@ -961,8 +820,30 @@ pub fn from_code(alpha4: &str) -> Option { ALPHA4_MAP.get(alpha4).cloned() } +#[cfg(feature = "serde")] +impl Serialize for CountryCode3 { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(self.code) + } +} -///CountryCode map with alpha4 Code key +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for CountryCode3 { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + use serde::de::Error; + let s = String::deserialize(deserializer)?; + let s_upper = s.to_uppercase(); + from_code(&s_upper) + .ok_or_else(|| D::Error::custom(format!("Invalid ISO 3166-3 code: {}", s))) + } +} +///CountryCode map with alpha4 Code key pub const ALPHA4_MAP: Map<&str, CountryCode3> = phf_map! { "BQAQ" => BQAQ, @@ -999,41 +880,8 @@ pub const ALPHA4_MAP: Map<&str, CountryCode3> = phf_map! { }; - ///ALL the Countrys struct -pub const ALL: & [CountryCode3] = &[ - -BQAQ, -BUMM, -BYAA, -CTKI, -CSHH, -DYBJ, -NQAQ, -TPTL, -FXFR, -AIDJ, -FQHH, -DDDE, -GEHH, -JTUM, -MIUM, -ANHH, -NTHH, -NHVU, -PCHH, -PZPA, -CSXX, -SKIN, -RHZW, -PUUM, -HVBF, -SUHH, -VDVN, -WKUM, -YDYE, -YUCS, -ZRCD, - +pub const ALL: &[CountryCode3] = &[ + BQAQ, BUMM, BYAA, CTKI, CSHH, DYBJ, NQAQ, TPTL, FXFR, AIDJ, FQHH, DDDE, GEHH, JTUM, MIUM, ANHH, + NTHH, NHVU, PCHH, PZPA, CSXX, SKIN, RHZW, PUUM, HVBF, SUHH, VDVN, WKUM, YDYE, YUCS, ZRCD, ]; - diff --git a/src/lib.rs b/src/lib.rs index 2d16f2e..49a3cb8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,25 +1,26 @@ - use phf::phf_map; use phf::Map; pub mod iso3166_2; pub mod iso3166_3; +#[cfg(all(direct_wasm, target_arch = "wasm32"))] +use js_sys::Array; +#[cfg(feature = "serde")] +use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::hash::Hash; -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] use wasm_bindgen::prelude::*; -#[cfg(all(direct_wasm,target_arch = "wasm32"))] -use js_sys::Array; /// # Sample code /// ``` /// let country = rust_iso3166::from_alpha2("AU"); -/// assert_eq!("AUS", country.unwrap().alpha3); +/// assert_eq!("AUS", country.unwrap().alpha3); /// let country = rust_iso3166::from_alpha3("AUS"); /// assert_eq!("AU", country.unwrap().alpha2); /// let country = rust_iso3166::from_numeric(036); /// assert_eq!("AUS", country.unwrap().alpha3); /// let country = rust_iso3166::from_numeric_str("036"); -/// assert_eq!("AUS", country.unwrap().alpha3); -/// +/// assert_eq!("AUS", country.unwrap().alpha3); +/// /// println!("{:?}", country); /// println!("{:?}", rust_iso3166::ALL); @@ -35,7 +36,7 @@ use js_sys::Array; /// ``` /// Data for each Country Code defined by ISO 3166-1 -#[cfg(all(direct_wasm,target_arch = "wasm32"))] +#[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct CountryCode { @@ -49,7 +50,7 @@ pub struct CountryCode { numeric: i32, } -#[cfg(any(not(direct_wasm),not(target_arch = "wasm32")))] +#[cfg(any(not(direct_wasm), not(target_arch = "wasm32")))] #[derive(Debug, Ord, PartialOrd, Copy, Clone, PartialEq, Eq, Hash)] pub struct CountryCode { ///English short name @@ -62,69 +63,91 @@ pub struct CountryCode { pub numeric: i32, } -#[cfg_attr(all(direct_wasm,target_arch = "wasm32"), wasm_bindgen)] +#[cfg_attr(all(direct_wasm, target_arch = "wasm32"), wasm_bindgen)] impl CountryCode { - - #[cfg(all(direct_wasm,target_arch = "wasm32"))] + #[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen(getter)] pub fn name(&self) -> String { self.name.into() } - #[cfg(all(direct_wasm,target_arch = "wasm32"))] + #[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen(getter)] pub fn alpha2(&self) -> String { self.alpha2.into() } - - #[cfg(all(direct_wasm,target_arch = "wasm32"))] + + #[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen(getter)] pub fn alpha3(&self) -> String { self.alpha3.into() } - #[cfg(all(direct_wasm,target_arch = "wasm32"))] + #[cfg(all(direct_wasm, target_arch = "wasm32"))] #[wasm_bindgen(getter)] pub fn numeric(&self) -> i32 { self.numeric } ///Return len 3 String for CountryCode numeric - pub fn numeric_str (&self) -> String { + pub fn numeric_str(&self) -> String { format!("{:03}", self.numeric) } ///Return Subdivision for ISO 3166-2 - #[cfg(any(not(direct_wasm),not(target_arch = "wasm32")))] - pub fn subdivisions (&self) -> Option<&[iso3166_2::Subdivision]> { + #[cfg(any(not(direct_wasm), not(target_arch = "wasm32")))] + pub fn subdivisions(&self) -> Option<&[iso3166_2::Subdivision]> { iso3166_2::SUBDIVISION_COUNTRY_MAP.get(self.alpha2).cloned() } - #[cfg(all(direct_wasm,target_arch = "wasm32"))] - pub fn subdivisions (&self) -> Array { + #[cfg(all(direct_wasm, target_arch = "wasm32"))] + pub fn subdivisions(&self) -> Array { let ps = iso3166_2::SUBDIVISION_COUNTRY_MAP.get(self.alpha2).cloned(); - let mut vector: Vec = Vec::new(); + let mut vector: Vec = Vec::new(); match ps { Some(p) => { for i in 0..p.len() { - vector.push(p[i]) - } - }, - None => { - - }, + vector.push(p[i]) + } + } + None => {} } vector.into_iter().map(JsValue::from).collect() } } + +#[cfg(feature = "serde")] +impl Serialize for CountryCode { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(self.alpha2) + } +} + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for CountryCode { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + use serde::de::Error; + let s = String::deserialize(deserializer)?; + let s_upper = s.to_uppercase(); + from_alpha2(&s_upper) + .or_else(|| from_alpha3(&s_upper)) + .ok_or_else(|| D::Error::custom(format!("Invalid country code: {}", s))) + } +} /// Returns the CountryCode with the given Alpha2 code, if exists. /// #Sample /// ``` /// let country = rust_iso3166::from_alpha2("AU"); /// assert_eq!("AUS", country.unwrap().alpha3); /// ``` -#[cfg_attr(all(direct_wasm,target_arch = "wasm32"), wasm_bindgen)] +#[cfg_attr(all(direct_wasm, target_arch = "wasm32"), wasm_bindgen)] pub fn from_alpha2(alpha2: &str) -> Option { ALPHA2_MAP.get(alpha2).cloned() } @@ -135,7 +158,7 @@ pub fn from_alpha2(alpha2: &str) -> Option { /// let country = rust_iso3166::from_alpha3("AUS"); /// assert_eq!(036, country.unwrap().numeric); /// ``` -#[cfg_attr(all(direct_wasm,target_arch = "wasm32"), wasm_bindgen)] +#[cfg_attr(all(direct_wasm, target_arch = "wasm32"), wasm_bindgen)] pub fn from_alpha3(alpha3: &str) -> Option { ALPHA3_MAP.get(alpha3).cloned() } @@ -146,7 +169,7 @@ pub fn from_alpha3(alpha3: &str) -> Option { /// let country = rust_iso3166::from_numeric(036); /// assert_eq!("AUS", country.unwrap().alpha3); /// ``` -#[cfg_attr(all(direct_wasm,target_arch = "wasm32"), wasm_bindgen)] +#[cfg_attr(all(direct_wasm, target_arch = "wasm32"), wasm_bindgen)] pub fn from_numeric(numeric: i32) -> Option { let k = format!("{:03}", numeric); NUMERIC_MAP.get(&k).cloned() @@ -158,13 +181,11 @@ pub fn from_numeric(numeric: i32) -> Option { /// let country = rust_iso3166::from_numeric_str("036"); /// assert_eq!("AUS", country.unwrap().alpha3); /// ``` -#[cfg_attr(all(direct_wasm,target_arch = "wasm32"), wasm_bindgen)] +#[cfg_attr(all(direct_wasm, target_arch = "wasm32"), wasm_bindgen)] pub fn from_numeric_str(numeric: &str) -> Option { NUMERIC_MAP.get(numeric).cloned() } - - pub const AF: CountryCode = CountryCode { name: "Afghanistan", alpha2: "AF", @@ -172,7 +193,6 @@ pub const AF: CountryCode = CountryCode { numeric: 4, }; - pub const AX: CountryCode = CountryCode { name: "Åland Islands", alpha2: "AX", @@ -180,7 +200,6 @@ pub const AX: CountryCode = CountryCode { numeric: 248, }; - pub const AL: CountryCode = CountryCode { name: "Albania", alpha2: "AL", @@ -188,7 +207,6 @@ pub const AL: CountryCode = CountryCode { numeric: 8, }; - pub const DZ: CountryCode = CountryCode { name: "Algeria", alpha2: "DZ", @@ -196,7 +214,6 @@ pub const DZ: CountryCode = CountryCode { numeric: 12, }; - pub const AS: CountryCode = CountryCode { name: "American Samoa", alpha2: "AS", @@ -204,7 +221,6 @@ pub const AS: CountryCode = CountryCode { numeric: 16, }; - pub const AD: CountryCode = CountryCode { name: "Andorra", alpha2: "AD", @@ -212,7 +228,6 @@ pub const AD: CountryCode = CountryCode { numeric: 20, }; - pub const AO: CountryCode = CountryCode { name: "Angola", alpha2: "AO", @@ -220,7 +235,6 @@ pub const AO: CountryCode = CountryCode { numeric: 24, }; - pub const AI: CountryCode = CountryCode { name: "Anguilla", alpha2: "AI", @@ -228,7 +242,6 @@ pub const AI: CountryCode = CountryCode { numeric: 660, }; - pub const AQ: CountryCode = CountryCode { name: "Antarctica", alpha2: "AQ", @@ -236,7 +249,6 @@ pub const AQ: CountryCode = CountryCode { numeric: 10, }; - pub const AG: CountryCode = CountryCode { name: "Antigua and Barbuda", alpha2: "AG", @@ -244,7 +256,6 @@ pub const AG: CountryCode = CountryCode { numeric: 28, }; - pub const AR: CountryCode = CountryCode { name: "Argentina", alpha2: "AR", @@ -252,7 +263,6 @@ pub const AR: CountryCode = CountryCode { numeric: 32, }; - pub const AM: CountryCode = CountryCode { name: "Armenia", alpha2: "AM", @@ -260,7 +270,6 @@ pub const AM: CountryCode = CountryCode { numeric: 51, }; - pub const AW: CountryCode = CountryCode { name: "Aruba", alpha2: "AW", @@ -268,7 +277,6 @@ pub const AW: CountryCode = CountryCode { numeric: 533, }; - pub const AU: CountryCode = CountryCode { name: "Australia", alpha2: "AU", @@ -276,7 +284,6 @@ pub const AU: CountryCode = CountryCode { numeric: 36, }; - pub const AT: CountryCode = CountryCode { name: "Austria", alpha2: "AT", @@ -284,7 +291,6 @@ pub const AT: CountryCode = CountryCode { numeric: 40, }; - pub const AZ: CountryCode = CountryCode { name: "Azerbaijan", alpha2: "AZ", @@ -292,7 +298,6 @@ pub const AZ: CountryCode = CountryCode { numeric: 31, }; - pub const BS: CountryCode = CountryCode { name: "Bahamas", alpha2: "BS", @@ -300,7 +305,6 @@ pub const BS: CountryCode = CountryCode { numeric: 44, }; - pub const BH: CountryCode = CountryCode { name: "Bahrain", alpha2: "BH", @@ -308,7 +312,6 @@ pub const BH: CountryCode = CountryCode { numeric: 48, }; - pub const BD: CountryCode = CountryCode { name: "Bangladesh", alpha2: "BD", @@ -316,7 +319,6 @@ pub const BD: CountryCode = CountryCode { numeric: 50, }; - pub const BB: CountryCode = CountryCode { name: "Barbados", alpha2: "BB", @@ -324,7 +326,6 @@ pub const BB: CountryCode = CountryCode { numeric: 52, }; - pub const BY: CountryCode = CountryCode { name: "Belarus", alpha2: "BY", @@ -332,7 +333,6 @@ pub const BY: CountryCode = CountryCode { numeric: 112, }; - pub const BE: CountryCode = CountryCode { name: "Belgium", alpha2: "BE", @@ -340,7 +340,6 @@ pub const BE: CountryCode = CountryCode { numeric: 56, }; - pub const BZ: CountryCode = CountryCode { name: "Belize", alpha2: "BZ", @@ -348,7 +347,6 @@ pub const BZ: CountryCode = CountryCode { numeric: 84, }; - pub const BJ: CountryCode = CountryCode { name: "Benin", alpha2: "BJ", @@ -356,7 +354,6 @@ pub const BJ: CountryCode = CountryCode { numeric: 204, }; - pub const BM: CountryCode = CountryCode { name: "Bermuda", alpha2: "BM", @@ -364,7 +361,6 @@ pub const BM: CountryCode = CountryCode { numeric: 60, }; - pub const BT: CountryCode = CountryCode { name: "Bhutan", alpha2: "BT", @@ -372,7 +368,6 @@ pub const BT: CountryCode = CountryCode { numeric: 64, }; - pub const BO: CountryCode = CountryCode { name: "Bolivia (Plurinational State of)", alpha2: "BO", @@ -380,7 +375,6 @@ pub const BO: CountryCode = CountryCode { numeric: 68, }; - pub const BQ: CountryCode = CountryCode { name: "Bonaire, Sint Eustatius and Saba[c]", alpha2: "BQ", @@ -388,7 +382,6 @@ pub const BQ: CountryCode = CountryCode { numeric: 535, }; - pub const BA: CountryCode = CountryCode { name: "Bosnia and Herzegovina", alpha2: "BA", @@ -396,7 +389,6 @@ pub const BA: CountryCode = CountryCode { numeric: 70, }; - pub const BW: CountryCode = CountryCode { name: "Botswana", alpha2: "BW", @@ -404,7 +396,6 @@ pub const BW: CountryCode = CountryCode { numeric: 72, }; - pub const BV: CountryCode = CountryCode { name: "Bouvet Island", alpha2: "BV", @@ -412,7 +403,6 @@ pub const BV: CountryCode = CountryCode { numeric: 74, }; - pub const BR: CountryCode = CountryCode { name: "Brazil", alpha2: "BR", @@ -420,7 +410,6 @@ pub const BR: CountryCode = CountryCode { numeric: 76, }; - pub const IO: CountryCode = CountryCode { name: "British Indian Ocean Territory", alpha2: "IO", @@ -428,7 +417,6 @@ pub const IO: CountryCode = CountryCode { numeric: 86, }; - pub const BN: CountryCode = CountryCode { name: "Brunei Darussalam", alpha2: "BN", @@ -436,7 +424,6 @@ pub const BN: CountryCode = CountryCode { numeric: 96, }; - pub const BG: CountryCode = CountryCode { name: "Bulgaria", alpha2: "BG", @@ -444,7 +431,6 @@ pub const BG: CountryCode = CountryCode { numeric: 100, }; - pub const BF: CountryCode = CountryCode { name: "Burkina Faso", alpha2: "BF", @@ -452,7 +438,6 @@ pub const BF: CountryCode = CountryCode { numeric: 854, }; - pub const BI: CountryCode = CountryCode { name: "Burundi", alpha2: "BI", @@ -460,7 +445,6 @@ pub const BI: CountryCode = CountryCode { numeric: 108, }; - pub const CV: CountryCode = CountryCode { name: "Cabo Verde", alpha2: "CV", @@ -468,7 +452,6 @@ pub const CV: CountryCode = CountryCode { numeric: 132, }; - pub const KH: CountryCode = CountryCode { name: "Cambodia", alpha2: "KH", @@ -476,7 +459,6 @@ pub const KH: CountryCode = CountryCode { numeric: 116, }; - pub const CM: CountryCode = CountryCode { name: "Cameroon", alpha2: "CM", @@ -484,7 +466,6 @@ pub const CM: CountryCode = CountryCode { numeric: 120, }; - pub const CA: CountryCode = CountryCode { name: "Canada", alpha2: "CA", @@ -492,7 +473,6 @@ pub const CA: CountryCode = CountryCode { numeric: 124, }; - pub const KY: CountryCode = CountryCode { name: "Cayman Islands", alpha2: "KY", @@ -500,7 +480,6 @@ pub const KY: CountryCode = CountryCode { numeric: 136, }; - pub const CF: CountryCode = CountryCode { name: "Central African Republic", alpha2: "CF", @@ -508,7 +487,6 @@ pub const CF: CountryCode = CountryCode { numeric: 140, }; - pub const TD: CountryCode = CountryCode { name: "Chad", alpha2: "TD", @@ -516,7 +494,6 @@ pub const TD: CountryCode = CountryCode { numeric: 148, }; - pub const CL: CountryCode = CountryCode { name: "Chile", alpha2: "CL", @@ -524,7 +501,6 @@ pub const CL: CountryCode = CountryCode { numeric: 152, }; - pub const CN: CountryCode = CountryCode { name: "China", alpha2: "CN", @@ -532,7 +508,6 @@ pub const CN: CountryCode = CountryCode { numeric: 156, }; - pub const CX: CountryCode = CountryCode { name: "Christmas Island", alpha2: "CX", @@ -540,7 +515,6 @@ pub const CX: CountryCode = CountryCode { numeric: 162, }; - pub const CC: CountryCode = CountryCode { name: "Cocos (Keeling) Islands", alpha2: "CC", @@ -548,7 +522,6 @@ pub const CC: CountryCode = CountryCode { numeric: 166, }; - pub const CO: CountryCode = CountryCode { name: "Colombia", alpha2: "CO", @@ -556,7 +529,6 @@ pub const CO: CountryCode = CountryCode { numeric: 170, }; - pub const KM: CountryCode = CountryCode { name: "Comoros", alpha2: "KM", @@ -564,7 +536,6 @@ pub const KM: CountryCode = CountryCode { numeric: 174, }; - pub const CG: CountryCode = CountryCode { name: "Congo", alpha2: "CG", @@ -572,7 +543,6 @@ pub const CG: CountryCode = CountryCode { numeric: 178, }; - pub const CD: CountryCode = CountryCode { name: "Congo, Democratic Republic of the", alpha2: "CD", @@ -580,7 +550,6 @@ pub const CD: CountryCode = CountryCode { numeric: 180, }; - pub const CK: CountryCode = CountryCode { name: "Cook Islands", alpha2: "CK", @@ -588,7 +557,6 @@ pub const CK: CountryCode = CountryCode { numeric: 184, }; - pub const CR: CountryCode = CountryCode { name: "Costa Rica", alpha2: "CR", @@ -596,7 +564,6 @@ pub const CR: CountryCode = CountryCode { numeric: 188, }; - pub const CI: CountryCode = CountryCode { name: "Côte d'Ivoire", alpha2: "CI", @@ -604,7 +571,6 @@ pub const CI: CountryCode = CountryCode { numeric: 384, }; - pub const HR: CountryCode = CountryCode { name: "Croatia", alpha2: "HR", @@ -612,7 +578,6 @@ pub const HR: CountryCode = CountryCode { numeric: 191, }; - pub const CU: CountryCode = CountryCode { name: "Cuba", alpha2: "CU", @@ -620,7 +585,6 @@ pub const CU: CountryCode = CountryCode { numeric: 192, }; - pub const CW: CountryCode = CountryCode { name: "Curaçao", alpha2: "CW", @@ -628,7 +592,6 @@ pub const CW: CountryCode = CountryCode { numeric: 531, }; - pub const CY: CountryCode = CountryCode { name: "Cyprus", alpha2: "CY", @@ -636,7 +599,6 @@ pub const CY: CountryCode = CountryCode { numeric: 196, }; - pub const CZ: CountryCode = CountryCode { name: "Czechia", alpha2: "CZ", @@ -644,7 +606,6 @@ pub const CZ: CountryCode = CountryCode { numeric: 203, }; - pub const DK: CountryCode = CountryCode { name: "Denmark", alpha2: "DK", @@ -652,7 +613,6 @@ pub const DK: CountryCode = CountryCode { numeric: 208, }; - pub const DJ: CountryCode = CountryCode { name: "Djibouti", alpha2: "DJ", @@ -660,7 +620,6 @@ pub const DJ: CountryCode = CountryCode { numeric: 262, }; - pub const DM: CountryCode = CountryCode { name: "Dominica", alpha2: "DM", @@ -668,7 +627,6 @@ pub const DM: CountryCode = CountryCode { numeric: 212, }; - pub const DO: CountryCode = CountryCode { name: "Dominican Republic", alpha2: "DO", @@ -676,7 +634,6 @@ pub const DO: CountryCode = CountryCode { numeric: 214, }; - pub const EC: CountryCode = CountryCode { name: "Ecuador", alpha2: "EC", @@ -684,7 +641,6 @@ pub const EC: CountryCode = CountryCode { numeric: 218, }; - pub const EG: CountryCode = CountryCode { name: "Egypt", alpha2: "EG", @@ -692,7 +648,6 @@ pub const EG: CountryCode = CountryCode { numeric: 818, }; - pub const SV: CountryCode = CountryCode { name: "El Salvador", alpha2: "SV", @@ -700,7 +655,6 @@ pub const SV: CountryCode = CountryCode { numeric: 222, }; - pub const GQ: CountryCode = CountryCode { name: "Equatorial Guinea", alpha2: "GQ", @@ -708,7 +662,6 @@ pub const GQ: CountryCode = CountryCode { numeric: 226, }; - pub const ER: CountryCode = CountryCode { name: "Eritrea", alpha2: "ER", @@ -716,7 +669,6 @@ pub const ER: CountryCode = CountryCode { numeric: 232, }; - pub const EE: CountryCode = CountryCode { name: "Estonia", alpha2: "EE", @@ -724,7 +676,6 @@ pub const EE: CountryCode = CountryCode { numeric: 233, }; - pub const SZ: CountryCode = CountryCode { name: "Eswatini", alpha2: "SZ", @@ -732,7 +683,6 @@ pub const SZ: CountryCode = CountryCode { numeric: 748, }; - pub const ET: CountryCode = CountryCode { name: "Ethiopia", alpha2: "ET", @@ -740,7 +690,6 @@ pub const ET: CountryCode = CountryCode { numeric: 231, }; - pub const FK: CountryCode = CountryCode { name: "Falkland Islands (Malvinas)", alpha2: "FK", @@ -748,7 +697,6 @@ pub const FK: CountryCode = CountryCode { numeric: 238, }; - pub const FO: CountryCode = CountryCode { name: "Faroe Islands", alpha2: "FO", @@ -756,7 +704,6 @@ pub const FO: CountryCode = CountryCode { numeric: 234, }; - pub const FJ: CountryCode = CountryCode { name: "Fiji", alpha2: "FJ", @@ -764,7 +711,6 @@ pub const FJ: CountryCode = CountryCode { numeric: 242, }; - pub const FI: CountryCode = CountryCode { name: "Finland", alpha2: "FI", @@ -772,7 +718,6 @@ pub const FI: CountryCode = CountryCode { numeric: 246, }; - pub const FR: CountryCode = CountryCode { name: "France", alpha2: "FR", @@ -780,7 +725,6 @@ pub const FR: CountryCode = CountryCode { numeric: 250, }; - pub const GF: CountryCode = CountryCode { name: "French Guiana", alpha2: "GF", @@ -788,7 +732,6 @@ pub const GF: CountryCode = CountryCode { numeric: 254, }; - pub const PF: CountryCode = CountryCode { name: "French Polynesia", alpha2: "PF", @@ -796,7 +739,6 @@ pub const PF: CountryCode = CountryCode { numeric: 258, }; - pub const TF: CountryCode = CountryCode { name: "French Southern Territories", alpha2: "TF", @@ -804,7 +746,6 @@ pub const TF: CountryCode = CountryCode { numeric: 260, }; - pub const GA: CountryCode = CountryCode { name: "Gabon", alpha2: "GA", @@ -812,7 +753,6 @@ pub const GA: CountryCode = CountryCode { numeric: 266, }; - pub const GM: CountryCode = CountryCode { name: "Gambia", alpha2: "GM", @@ -820,7 +760,6 @@ pub const GM: CountryCode = CountryCode { numeric: 270, }; - pub const GE: CountryCode = CountryCode { name: "Georgia", alpha2: "GE", @@ -828,7 +767,6 @@ pub const GE: CountryCode = CountryCode { numeric: 268, }; - pub const DE: CountryCode = CountryCode { name: "Germany", alpha2: "DE", @@ -836,7 +774,6 @@ pub const DE: CountryCode = CountryCode { numeric: 276, }; - pub const GH: CountryCode = CountryCode { name: "Ghana", alpha2: "GH", @@ -844,7 +781,6 @@ pub const GH: CountryCode = CountryCode { numeric: 288, }; - pub const GI: CountryCode = CountryCode { name: "Gibraltar", alpha2: "GI", @@ -852,7 +788,6 @@ pub const GI: CountryCode = CountryCode { numeric: 292, }; - pub const GR: CountryCode = CountryCode { name: "Greece", alpha2: "GR", @@ -860,7 +795,6 @@ pub const GR: CountryCode = CountryCode { numeric: 300, }; - pub const GL: CountryCode = CountryCode { name: "Greenland", alpha2: "GL", @@ -868,7 +802,6 @@ pub const GL: CountryCode = CountryCode { numeric: 304, }; - pub const GD: CountryCode = CountryCode { name: "Grenada", alpha2: "GD", @@ -876,7 +809,6 @@ pub const GD: CountryCode = CountryCode { numeric: 308, }; - pub const GP: CountryCode = CountryCode { name: "Guadeloupe", alpha2: "GP", @@ -884,7 +816,6 @@ pub const GP: CountryCode = CountryCode { numeric: 312, }; - pub const GU: CountryCode = CountryCode { name: "Guam", alpha2: "GU", @@ -892,7 +823,6 @@ pub const GU: CountryCode = CountryCode { numeric: 316, }; - pub const GT: CountryCode = CountryCode { name: "Guatemala", alpha2: "GT", @@ -900,7 +830,6 @@ pub const GT: CountryCode = CountryCode { numeric: 320, }; - pub const GG: CountryCode = CountryCode { name: "Guernsey", alpha2: "GG", @@ -908,7 +837,6 @@ pub const GG: CountryCode = CountryCode { numeric: 831, }; - pub const GN: CountryCode = CountryCode { name: "Guinea", alpha2: "GN", @@ -916,7 +844,6 @@ pub const GN: CountryCode = CountryCode { numeric: 324, }; - pub const GW: CountryCode = CountryCode { name: "Guinea-Bissau", alpha2: "GW", @@ -924,7 +851,6 @@ pub const GW: CountryCode = CountryCode { numeric: 624, }; - pub const GY: CountryCode = CountryCode { name: "Guyana", alpha2: "GY", @@ -932,7 +858,6 @@ pub const GY: CountryCode = CountryCode { numeric: 328, }; - pub const HT: CountryCode = CountryCode { name: "Haiti", alpha2: "HT", @@ -940,7 +865,6 @@ pub const HT: CountryCode = CountryCode { numeric: 332, }; - pub const HM: CountryCode = CountryCode { name: "Heard Island and McDonald Islands", alpha2: "HM", @@ -948,7 +872,6 @@ pub const HM: CountryCode = CountryCode { numeric: 334, }; - pub const VA: CountryCode = CountryCode { name: "Holy See", alpha2: "VA", @@ -956,7 +879,6 @@ pub const VA: CountryCode = CountryCode { numeric: 336, }; - pub const HN: CountryCode = CountryCode { name: "Honduras", alpha2: "HN", @@ -964,7 +886,6 @@ pub const HN: CountryCode = CountryCode { numeric: 340, }; - pub const HK: CountryCode = CountryCode { name: "Hong Kong", alpha2: "HK", @@ -972,7 +893,6 @@ pub const HK: CountryCode = CountryCode { numeric: 344, }; - pub const HU: CountryCode = CountryCode { name: "Hungary", alpha2: "HU", @@ -980,7 +900,6 @@ pub const HU: CountryCode = CountryCode { numeric: 348, }; - pub const IS: CountryCode = CountryCode { name: "Iceland", alpha2: "IS", @@ -988,7 +907,6 @@ pub const IS: CountryCode = CountryCode { numeric: 352, }; - pub const IN: CountryCode = CountryCode { name: "India", alpha2: "IN", @@ -996,7 +914,6 @@ pub const IN: CountryCode = CountryCode { numeric: 356, }; - pub const ID: CountryCode = CountryCode { name: "Indonesia", alpha2: "ID", @@ -1004,7 +921,6 @@ pub const ID: CountryCode = CountryCode { numeric: 360, }; - pub const IR: CountryCode = CountryCode { name: "Iran (Islamic Republic of)", alpha2: "IR", @@ -1012,7 +928,6 @@ pub const IR: CountryCode = CountryCode { numeric: 364, }; - pub const IQ: CountryCode = CountryCode { name: "Iraq", alpha2: "IQ", @@ -1020,7 +935,6 @@ pub const IQ: CountryCode = CountryCode { numeric: 368, }; - pub const IE: CountryCode = CountryCode { name: "Ireland", alpha2: "IE", @@ -1028,7 +942,6 @@ pub const IE: CountryCode = CountryCode { numeric: 372, }; - pub const IM: CountryCode = CountryCode { name: "Isle of Man", alpha2: "IM", @@ -1036,7 +949,6 @@ pub const IM: CountryCode = CountryCode { numeric: 833, }; - pub const IL: CountryCode = CountryCode { name: "Israel", alpha2: "IL", @@ -1044,7 +956,6 @@ pub const IL: CountryCode = CountryCode { numeric: 376, }; - pub const IT: CountryCode = CountryCode { name: "Italy", alpha2: "IT", @@ -1052,7 +963,6 @@ pub const IT: CountryCode = CountryCode { numeric: 380, }; - pub const JM: CountryCode = CountryCode { name: "Jamaica", alpha2: "JM", @@ -1060,7 +970,6 @@ pub const JM: CountryCode = CountryCode { numeric: 388, }; - pub const JP: CountryCode = CountryCode { name: "Japan", alpha2: "JP", @@ -1068,7 +977,6 @@ pub const JP: CountryCode = CountryCode { numeric: 392, }; - pub const JE: CountryCode = CountryCode { name: "Jersey", alpha2: "JE", @@ -1076,7 +984,6 @@ pub const JE: CountryCode = CountryCode { numeric: 832, }; - pub const JO: CountryCode = CountryCode { name: "Jordan", alpha2: "JO", @@ -1084,7 +991,6 @@ pub const JO: CountryCode = CountryCode { numeric: 400, }; - pub const KZ: CountryCode = CountryCode { name: "Kazakhstan", alpha2: "KZ", @@ -1092,7 +998,6 @@ pub const KZ: CountryCode = CountryCode { numeric: 398, }; - pub const KE: CountryCode = CountryCode { name: "Kenya", alpha2: "KE", @@ -1100,7 +1005,6 @@ pub const KE: CountryCode = CountryCode { numeric: 404, }; - pub const KI: CountryCode = CountryCode { name: "Kiribati", alpha2: "KI", @@ -1108,7 +1012,6 @@ pub const KI: CountryCode = CountryCode { numeric: 296, }; - pub const KP: CountryCode = CountryCode { name: "Korea (Democratic People's Republic of)", alpha2: "KP", @@ -1116,7 +1019,6 @@ pub const KP: CountryCode = CountryCode { numeric: 408, }; - pub const KR: CountryCode = CountryCode { name: "Korea, Republic of", alpha2: "KR", @@ -1124,7 +1026,6 @@ pub const KR: CountryCode = CountryCode { numeric: 410, }; - pub const KW: CountryCode = CountryCode { name: "Kuwait", alpha2: "KW", @@ -1132,7 +1033,6 @@ pub const KW: CountryCode = CountryCode { numeric: 414, }; - pub const KG: CountryCode = CountryCode { name: "Kyrgyzstan", alpha2: "KG", @@ -1140,7 +1040,6 @@ pub const KG: CountryCode = CountryCode { numeric: 417, }; - pub const LA: CountryCode = CountryCode { name: "Lao People's Democratic Republic", alpha2: "LA", @@ -1148,7 +1047,6 @@ pub const LA: CountryCode = CountryCode { numeric: 418, }; - pub const LV: CountryCode = CountryCode { name: "Latvia", alpha2: "LV", @@ -1156,7 +1054,6 @@ pub const LV: CountryCode = CountryCode { numeric: 428, }; - pub const LB: CountryCode = CountryCode { name: "Lebanon", alpha2: "LB", @@ -1164,7 +1061,6 @@ pub const LB: CountryCode = CountryCode { numeric: 422, }; - pub const LS: CountryCode = CountryCode { name: "Lesotho", alpha2: "LS", @@ -1172,7 +1068,6 @@ pub const LS: CountryCode = CountryCode { numeric: 426, }; - pub const LR: CountryCode = CountryCode { name: "Liberia", alpha2: "LR", @@ -1180,7 +1075,6 @@ pub const LR: CountryCode = CountryCode { numeric: 430, }; - pub const LY: CountryCode = CountryCode { name: "Libya", alpha2: "LY", @@ -1188,7 +1082,6 @@ pub const LY: CountryCode = CountryCode { numeric: 434, }; - pub const LI: CountryCode = CountryCode { name: "Liechtenstein", alpha2: "LI", @@ -1196,7 +1089,6 @@ pub const LI: CountryCode = CountryCode { numeric: 438, }; - pub const LT: CountryCode = CountryCode { name: "Lithuania", alpha2: "LT", @@ -1204,7 +1096,6 @@ pub const LT: CountryCode = CountryCode { numeric: 440, }; - pub const LU: CountryCode = CountryCode { name: "Luxembourg", alpha2: "LU", @@ -1212,7 +1103,6 @@ pub const LU: CountryCode = CountryCode { numeric: 442, }; - pub const MO: CountryCode = CountryCode { name: "Macao", alpha2: "MO", @@ -1220,7 +1110,6 @@ pub const MO: CountryCode = CountryCode { numeric: 446, }; - pub const MG: CountryCode = CountryCode { name: "Madagascar", alpha2: "MG", @@ -1228,7 +1117,6 @@ pub const MG: CountryCode = CountryCode { numeric: 450, }; - pub const MW: CountryCode = CountryCode { name: "Malawi", alpha2: "MW", @@ -1236,7 +1124,6 @@ pub const MW: CountryCode = CountryCode { numeric: 454, }; - pub const MY: CountryCode = CountryCode { name: "Malaysia", alpha2: "MY", @@ -1244,7 +1131,6 @@ pub const MY: CountryCode = CountryCode { numeric: 458, }; - pub const MV: CountryCode = CountryCode { name: "Maldives", alpha2: "MV", @@ -1252,7 +1138,6 @@ pub const MV: CountryCode = CountryCode { numeric: 462, }; - pub const ML: CountryCode = CountryCode { name: "Mali", alpha2: "ML", @@ -1260,7 +1145,6 @@ pub const ML: CountryCode = CountryCode { numeric: 466, }; - pub const MT: CountryCode = CountryCode { name: "Malta", alpha2: "MT", @@ -1268,7 +1152,6 @@ pub const MT: CountryCode = CountryCode { numeric: 470, }; - pub const MH: CountryCode = CountryCode { name: "Marshall Islands", alpha2: "MH", @@ -1276,7 +1159,6 @@ pub const MH: CountryCode = CountryCode { numeric: 584, }; - pub const MQ: CountryCode = CountryCode { name: "Martinique", alpha2: "MQ", @@ -1284,7 +1166,6 @@ pub const MQ: CountryCode = CountryCode { numeric: 474, }; - pub const MR: CountryCode = CountryCode { name: "Mauritania", alpha2: "MR", @@ -1292,7 +1173,6 @@ pub const MR: CountryCode = CountryCode { numeric: 478, }; - pub const MU: CountryCode = CountryCode { name: "Mauritius", alpha2: "MU", @@ -1300,7 +1180,6 @@ pub const MU: CountryCode = CountryCode { numeric: 480, }; - pub const YT: CountryCode = CountryCode { name: "Mayotte", alpha2: "YT", @@ -1308,7 +1187,6 @@ pub const YT: CountryCode = CountryCode { numeric: 175, }; - pub const MX: CountryCode = CountryCode { name: "Mexico", alpha2: "MX", @@ -1316,7 +1194,6 @@ pub const MX: CountryCode = CountryCode { numeric: 484, }; - pub const FM: CountryCode = CountryCode { name: "Micronesia (Federated States of)", alpha2: "FM", @@ -1324,7 +1201,6 @@ pub const FM: CountryCode = CountryCode { numeric: 583, }; - pub const MD: CountryCode = CountryCode { name: "Moldova, Republic of", alpha2: "MD", @@ -1332,7 +1208,6 @@ pub const MD: CountryCode = CountryCode { numeric: 498, }; - pub const MC: CountryCode = CountryCode { name: "Monaco", alpha2: "MC", @@ -1340,7 +1215,6 @@ pub const MC: CountryCode = CountryCode { numeric: 492, }; - pub const MN: CountryCode = CountryCode { name: "Mongolia", alpha2: "MN", @@ -1348,7 +1222,6 @@ pub const MN: CountryCode = CountryCode { numeric: 496, }; - pub const ME: CountryCode = CountryCode { name: "Montenegro", alpha2: "ME", @@ -1356,7 +1229,6 @@ pub const ME: CountryCode = CountryCode { numeric: 499, }; - pub const MS: CountryCode = CountryCode { name: "Montserrat", alpha2: "MS", @@ -1364,7 +1236,6 @@ pub const MS: CountryCode = CountryCode { numeric: 500, }; - pub const MA: CountryCode = CountryCode { name: "Morocco", alpha2: "MA", @@ -1372,7 +1243,6 @@ pub const MA: CountryCode = CountryCode { numeric: 504, }; - pub const MZ: CountryCode = CountryCode { name: "Mozambique", alpha2: "MZ", @@ -1380,7 +1250,6 @@ pub const MZ: CountryCode = CountryCode { numeric: 508, }; - pub const MM: CountryCode = CountryCode { name: "Myanmar", alpha2: "MM", @@ -1388,7 +1257,6 @@ pub const MM: CountryCode = CountryCode { numeric: 104, }; - pub const NA: CountryCode = CountryCode { name: "Namibia", alpha2: "NA", @@ -1396,7 +1264,6 @@ pub const NA: CountryCode = CountryCode { numeric: 516, }; - pub const NR: CountryCode = CountryCode { name: "Nauru", alpha2: "NR", @@ -1404,7 +1271,6 @@ pub const NR: CountryCode = CountryCode { numeric: 520, }; - pub const NP: CountryCode = CountryCode { name: "Nepal", alpha2: "NP", @@ -1412,7 +1278,6 @@ pub const NP: CountryCode = CountryCode { numeric: 524, }; - pub const NL: CountryCode = CountryCode { name: "Netherlands", alpha2: "NL", @@ -1420,7 +1285,6 @@ pub const NL: CountryCode = CountryCode { numeric: 528, }; - pub const NC: CountryCode = CountryCode { name: "New Caledonia", alpha2: "NC", @@ -1428,7 +1292,6 @@ pub const NC: CountryCode = CountryCode { numeric: 540, }; - pub const NZ: CountryCode = CountryCode { name: "New Zealand", alpha2: "NZ", @@ -1436,7 +1299,6 @@ pub const NZ: CountryCode = CountryCode { numeric: 554, }; - pub const NI: CountryCode = CountryCode { name: "Nicaragua", alpha2: "NI", @@ -1444,7 +1306,6 @@ pub const NI: CountryCode = CountryCode { numeric: 558, }; - pub const NE: CountryCode = CountryCode { name: "Niger", alpha2: "NE", @@ -1452,7 +1313,6 @@ pub const NE: CountryCode = CountryCode { numeric: 562, }; - pub const NG: CountryCode = CountryCode { name: "Nigeria", alpha2: "NG", @@ -1460,7 +1320,6 @@ pub const NG: CountryCode = CountryCode { numeric: 566, }; - pub const NU: CountryCode = CountryCode { name: "Niue", alpha2: "NU", @@ -1468,7 +1327,6 @@ pub const NU: CountryCode = CountryCode { numeric: 570, }; - pub const NF: CountryCode = CountryCode { name: "Norfolk Island", alpha2: "NF", @@ -1476,7 +1334,6 @@ pub const NF: CountryCode = CountryCode { numeric: 574, }; - pub const MK: CountryCode = CountryCode { name: "North Macedonia", alpha2: "MK", @@ -1484,7 +1341,6 @@ pub const MK: CountryCode = CountryCode { numeric: 807, }; - pub const MP: CountryCode = CountryCode { name: "Northern Mariana Islands", alpha2: "MP", @@ -1492,7 +1348,6 @@ pub const MP: CountryCode = CountryCode { numeric: 580, }; - pub const NO: CountryCode = CountryCode { name: "Norway", alpha2: "NO", @@ -1500,7 +1355,6 @@ pub const NO: CountryCode = CountryCode { numeric: 578, }; - pub const OM: CountryCode = CountryCode { name: "Oman", alpha2: "OM", @@ -1508,7 +1362,6 @@ pub const OM: CountryCode = CountryCode { numeric: 512, }; - pub const PK: CountryCode = CountryCode { name: "Pakistan", alpha2: "PK", @@ -1516,7 +1369,6 @@ pub const PK: CountryCode = CountryCode { numeric: 586, }; - pub const PW: CountryCode = CountryCode { name: "Palau", alpha2: "PW", @@ -1524,7 +1376,6 @@ pub const PW: CountryCode = CountryCode { numeric: 585, }; - pub const PS: CountryCode = CountryCode { name: "Palestine, State of", alpha2: "PS", @@ -1532,7 +1383,6 @@ pub const PS: CountryCode = CountryCode { numeric: 275, }; - pub const PA: CountryCode = CountryCode { name: "Panama", alpha2: "PA", @@ -1540,7 +1390,6 @@ pub const PA: CountryCode = CountryCode { numeric: 591, }; - pub const PG: CountryCode = CountryCode { name: "Papua New Guinea", alpha2: "PG", @@ -1548,7 +1397,6 @@ pub const PG: CountryCode = CountryCode { numeric: 598, }; - pub const PY: CountryCode = CountryCode { name: "Paraguay", alpha2: "PY", @@ -1556,7 +1404,6 @@ pub const PY: CountryCode = CountryCode { numeric: 600, }; - pub const PE: CountryCode = CountryCode { name: "Peru", alpha2: "PE", @@ -1564,7 +1411,6 @@ pub const PE: CountryCode = CountryCode { numeric: 604, }; - pub const PH: CountryCode = CountryCode { name: "Philippines", alpha2: "PH", @@ -1572,7 +1418,6 @@ pub const PH: CountryCode = CountryCode { numeric: 608, }; - pub const PN: CountryCode = CountryCode { name: "Pitcairn", alpha2: "PN", @@ -1580,7 +1425,6 @@ pub const PN: CountryCode = CountryCode { numeric: 612, }; - pub const PL: CountryCode = CountryCode { name: "Poland", alpha2: "PL", @@ -1588,7 +1432,6 @@ pub const PL: CountryCode = CountryCode { numeric: 616, }; - pub const PT: CountryCode = CountryCode { name: "Portugal", alpha2: "PT", @@ -1596,7 +1439,6 @@ pub const PT: CountryCode = CountryCode { numeric: 620, }; - pub const PR: CountryCode = CountryCode { name: "Puerto Rico", alpha2: "PR", @@ -1604,7 +1446,6 @@ pub const PR: CountryCode = CountryCode { numeric: 630, }; - pub const QA: CountryCode = CountryCode { name: "Qatar", alpha2: "QA", @@ -1612,7 +1453,6 @@ pub const QA: CountryCode = CountryCode { numeric: 634, }; - pub const RE: CountryCode = CountryCode { name: "Réunion", alpha2: "RE", @@ -1620,7 +1460,6 @@ pub const RE: CountryCode = CountryCode { numeric: 638, }; - pub const RO: CountryCode = CountryCode { name: "Romania", alpha2: "RO", @@ -1628,7 +1467,6 @@ pub const RO: CountryCode = CountryCode { numeric: 642, }; - pub const RU: CountryCode = CountryCode { name: "Russian Federation", alpha2: "RU", @@ -1636,7 +1474,6 @@ pub const RU: CountryCode = CountryCode { numeric: 643, }; - pub const RW: CountryCode = CountryCode { name: "Rwanda", alpha2: "RW", @@ -1644,7 +1481,6 @@ pub const RW: CountryCode = CountryCode { numeric: 646, }; - pub const BL: CountryCode = CountryCode { name: "Saint Barthélemy", alpha2: "BL", @@ -1652,7 +1488,6 @@ pub const BL: CountryCode = CountryCode { numeric: 652, }; - pub const SH: CountryCode = CountryCode { name: "Saint Helena, Ascension and Tristan da Cunha[d]", alpha2: "SH", @@ -1660,7 +1495,6 @@ pub const SH: CountryCode = CountryCode { numeric: 654, }; - pub const KN: CountryCode = CountryCode { name: "Saint Kitts and Nevis", alpha2: "KN", @@ -1668,7 +1502,6 @@ pub const KN: CountryCode = CountryCode { numeric: 659, }; - pub const LC: CountryCode = CountryCode { name: "Saint Lucia", alpha2: "LC", @@ -1676,7 +1509,6 @@ pub const LC: CountryCode = CountryCode { numeric: 662, }; - pub const MF: CountryCode = CountryCode { name: "Saint Martin (French part)", alpha2: "MF", @@ -1684,7 +1516,6 @@ pub const MF: CountryCode = CountryCode { numeric: 663, }; - pub const PM: CountryCode = CountryCode { name: "Saint Pierre and Miquelon", alpha2: "PM", @@ -1692,7 +1523,6 @@ pub const PM: CountryCode = CountryCode { numeric: 666, }; - pub const VC: CountryCode = CountryCode { name: "Saint Vincent and the Grenadines", alpha2: "VC", @@ -1700,7 +1530,6 @@ pub const VC: CountryCode = CountryCode { numeric: 670, }; - pub const WS: CountryCode = CountryCode { name: "Samoa", alpha2: "WS", @@ -1708,7 +1537,6 @@ pub const WS: CountryCode = CountryCode { numeric: 882, }; - pub const SM: CountryCode = CountryCode { name: "San Marino", alpha2: "SM", @@ -1716,7 +1544,6 @@ pub const SM: CountryCode = CountryCode { numeric: 674, }; - pub const ST: CountryCode = CountryCode { name: "Sao Tome and Principe", alpha2: "ST", @@ -1724,7 +1551,6 @@ pub const ST: CountryCode = CountryCode { numeric: 678, }; - pub const SA: CountryCode = CountryCode { name: "Saudi Arabia", alpha2: "SA", @@ -1732,7 +1558,6 @@ pub const SA: CountryCode = CountryCode { numeric: 682, }; - pub const SN: CountryCode = CountryCode { name: "Senegal", alpha2: "SN", @@ -1740,7 +1565,6 @@ pub const SN: CountryCode = CountryCode { numeric: 686, }; - pub const RS: CountryCode = CountryCode { name: "Serbia", alpha2: "RS", @@ -1748,7 +1572,6 @@ pub const RS: CountryCode = CountryCode { numeric: 688, }; - pub const SC: CountryCode = CountryCode { name: "Seychelles", alpha2: "SC", @@ -1756,7 +1579,6 @@ pub const SC: CountryCode = CountryCode { numeric: 690, }; - pub const SL: CountryCode = CountryCode { name: "Sierra Leone", alpha2: "SL", @@ -1764,7 +1586,6 @@ pub const SL: CountryCode = CountryCode { numeric: 694, }; - pub const SG: CountryCode = CountryCode { name: "Singapore", alpha2: "SG", @@ -1772,7 +1593,6 @@ pub const SG: CountryCode = CountryCode { numeric: 702, }; - pub const SX: CountryCode = CountryCode { name: "Sint Maarten (Dutch part)", alpha2: "SX", @@ -1780,7 +1600,6 @@ pub const SX: CountryCode = CountryCode { numeric: 534, }; - pub const SK: CountryCode = CountryCode { name: "Slovakia", alpha2: "SK", @@ -1788,7 +1607,6 @@ pub const SK: CountryCode = CountryCode { numeric: 703, }; - pub const SI: CountryCode = CountryCode { name: "Slovenia", alpha2: "SI", @@ -1796,7 +1614,6 @@ pub const SI: CountryCode = CountryCode { numeric: 705, }; - pub const SB: CountryCode = CountryCode { name: "Solomon Islands", alpha2: "SB", @@ -1804,7 +1621,6 @@ pub const SB: CountryCode = CountryCode { numeric: 90, }; - pub const SO: CountryCode = CountryCode { name: "Somalia", alpha2: "SO", @@ -1812,7 +1628,6 @@ pub const SO: CountryCode = CountryCode { numeric: 706, }; - pub const ZA: CountryCode = CountryCode { name: "South Africa", alpha2: "ZA", @@ -1820,7 +1635,6 @@ pub const ZA: CountryCode = CountryCode { numeric: 710, }; - pub const GS: CountryCode = CountryCode { name: "South Georgia and the South Sandwich Islands", alpha2: "GS", @@ -1828,7 +1642,6 @@ pub const GS: CountryCode = CountryCode { numeric: 239, }; - pub const SS: CountryCode = CountryCode { name: "South Sudan", alpha2: "SS", @@ -1836,7 +1649,6 @@ pub const SS: CountryCode = CountryCode { numeric: 728, }; - pub const ES: CountryCode = CountryCode { name: "Spain", alpha2: "ES", @@ -1844,7 +1656,6 @@ pub const ES: CountryCode = CountryCode { numeric: 724, }; - pub const LK: CountryCode = CountryCode { name: "Sri Lanka", alpha2: "LK", @@ -1852,7 +1663,6 @@ pub const LK: CountryCode = CountryCode { numeric: 144, }; - pub const SD: CountryCode = CountryCode { name: "Sudan", alpha2: "SD", @@ -1860,7 +1670,6 @@ pub const SD: CountryCode = CountryCode { numeric: 729, }; - pub const SR: CountryCode = CountryCode { name: "Suriname", alpha2: "SR", @@ -1868,7 +1677,6 @@ pub const SR: CountryCode = CountryCode { numeric: 740, }; - pub const SJ: CountryCode = CountryCode { name: "Svalbard and Jan Mayen[e]", alpha2: "SJ", @@ -1876,7 +1684,6 @@ pub const SJ: CountryCode = CountryCode { numeric: 744, }; - pub const SE: CountryCode = CountryCode { name: "Sweden", alpha2: "SE", @@ -1884,7 +1691,6 @@ pub const SE: CountryCode = CountryCode { numeric: 752, }; - pub const CH: CountryCode = CountryCode { name: "Switzerland", alpha2: "CH", @@ -1892,7 +1698,6 @@ pub const CH: CountryCode = CountryCode { numeric: 756, }; - pub const SY: CountryCode = CountryCode { name: "Syrian Arab Republic", alpha2: "SY", @@ -1900,7 +1705,6 @@ pub const SY: CountryCode = CountryCode { numeric: 760, }; - pub const TW: CountryCode = CountryCode { name: "Taiwan, Province of China", alpha2: "TW", @@ -1908,7 +1712,6 @@ pub const TW: CountryCode = CountryCode { numeric: 158, }; - pub const TJ: CountryCode = CountryCode { name: "Tajikistan", alpha2: "TJ", @@ -1916,7 +1719,6 @@ pub const TJ: CountryCode = CountryCode { numeric: 762, }; - pub const TZ: CountryCode = CountryCode { name: "Tanzania, United Republic of", alpha2: "TZ", @@ -1924,7 +1726,6 @@ pub const TZ: CountryCode = CountryCode { numeric: 834, }; - pub const TH: CountryCode = CountryCode { name: "Thailand", alpha2: "TH", @@ -1932,7 +1733,6 @@ pub const TH: CountryCode = CountryCode { numeric: 764, }; - pub const TL: CountryCode = CountryCode { name: "Timor-Leste", alpha2: "TL", @@ -1940,7 +1740,6 @@ pub const TL: CountryCode = CountryCode { numeric: 626, }; - pub const TG: CountryCode = CountryCode { name: "Togo", alpha2: "TG", @@ -1948,7 +1747,6 @@ pub const TG: CountryCode = CountryCode { numeric: 768, }; - pub const TK: CountryCode = CountryCode { name: "Tokelau", alpha2: "TK", @@ -1956,7 +1754,6 @@ pub const TK: CountryCode = CountryCode { numeric: 772, }; - pub const TO: CountryCode = CountryCode { name: "Tonga", alpha2: "TO", @@ -1964,7 +1761,6 @@ pub const TO: CountryCode = CountryCode { numeric: 776, }; - pub const TT: CountryCode = CountryCode { name: "Trinidad and Tobago", alpha2: "TT", @@ -1972,7 +1768,6 @@ pub const TT: CountryCode = CountryCode { numeric: 780, }; - pub const TN: CountryCode = CountryCode { name: "Tunisia", alpha2: "TN", @@ -1980,7 +1775,6 @@ pub const TN: CountryCode = CountryCode { numeric: 788, }; - pub const TR: CountryCode = CountryCode { name: "Turkey", alpha2: "TR", @@ -1988,7 +1782,6 @@ pub const TR: CountryCode = CountryCode { numeric: 792, }; - pub const TM: CountryCode = CountryCode { name: "Turkmenistan", alpha2: "TM", @@ -1996,7 +1789,6 @@ pub const TM: CountryCode = CountryCode { numeric: 795, }; - pub const TC: CountryCode = CountryCode { name: "Turks and Caicos Islands", alpha2: "TC", @@ -2004,7 +1796,6 @@ pub const TC: CountryCode = CountryCode { numeric: 796, }; - pub const TV: CountryCode = CountryCode { name: "Tuvalu", alpha2: "TV", @@ -2012,7 +1803,6 @@ pub const TV: CountryCode = CountryCode { numeric: 798, }; - pub const UG: CountryCode = CountryCode { name: "Uganda", alpha2: "UG", @@ -2020,7 +1810,6 @@ pub const UG: CountryCode = CountryCode { numeric: 800, }; - pub const UA: CountryCode = CountryCode { name: "Ukraine", alpha2: "UA", @@ -2028,7 +1817,6 @@ pub const UA: CountryCode = CountryCode { numeric: 804, }; - pub const AE: CountryCode = CountryCode { name: "United Arab Emirates", alpha2: "AE", @@ -2036,7 +1824,6 @@ pub const AE: CountryCode = CountryCode { numeric: 784, }; - pub const GB: CountryCode = CountryCode { name: "United Kingdom of Great Britain and Northern Ireland", alpha2: "GB", @@ -2044,7 +1831,6 @@ pub const GB: CountryCode = CountryCode { numeric: 826, }; - pub const US: CountryCode = CountryCode { name: "United States of America", alpha2: "US", @@ -2052,7 +1838,6 @@ pub const US: CountryCode = CountryCode { numeric: 840, }; - pub const UM: CountryCode = CountryCode { name: "United States Minor Outlying Islands[f]", alpha2: "UM", @@ -2060,7 +1845,6 @@ pub const UM: CountryCode = CountryCode { numeric: 581, }; - pub const UY: CountryCode = CountryCode { name: "Uruguay", alpha2: "UY", @@ -2068,7 +1852,6 @@ pub const UY: CountryCode = CountryCode { numeric: 858, }; - pub const UZ: CountryCode = CountryCode { name: "Uzbekistan", alpha2: "UZ", @@ -2076,7 +1859,6 @@ pub const UZ: CountryCode = CountryCode { numeric: 860, }; - pub const VU: CountryCode = CountryCode { name: "Vanuatu", alpha2: "VU", @@ -2084,7 +1866,6 @@ pub const VU: CountryCode = CountryCode { numeric: 548, }; - pub const VE: CountryCode = CountryCode { name: "Venezuela (Bolivarian Republic of)", alpha2: "VE", @@ -2092,7 +1873,6 @@ pub const VE: CountryCode = CountryCode { numeric: 862, }; - pub const VN: CountryCode = CountryCode { name: "Viet Nam", alpha2: "VN", @@ -2100,7 +1880,6 @@ pub const VN: CountryCode = CountryCode { numeric: 704, }; - pub const VG: CountryCode = CountryCode { name: "Virgin Islands (British)", alpha2: "VG", @@ -2108,7 +1887,6 @@ pub const VG: CountryCode = CountryCode { numeric: 92, }; - pub const VI: CountryCode = CountryCode { name: "Virgin Islands (U.S.)", alpha2: "VI", @@ -2116,7 +1894,6 @@ pub const VI: CountryCode = CountryCode { numeric: 850, }; - pub const WF: CountryCode = CountryCode { name: "Wallis and Futuna", alpha2: "WF", @@ -2124,7 +1901,6 @@ pub const WF: CountryCode = CountryCode { numeric: 876, }; - pub const EH: CountryCode = CountryCode { name: "Western Sahara", alpha2: "EH", @@ -2132,7 +1908,6 @@ pub const EH: CountryCode = CountryCode { numeric: 732, }; - pub const YE: CountryCode = CountryCode { name: "Yemen", alpha2: "YE", @@ -2140,7 +1915,6 @@ pub const YE: CountryCode = CountryCode { numeric: 887, }; - pub const ZM: CountryCode = CountryCode { name: "Zambia", alpha2: "ZM", @@ -2148,7 +1922,6 @@ pub const ZM: CountryCode = CountryCode { numeric: 894, }; - pub const ZW: CountryCode = CountryCode { name: "Zimbabwe", alpha2: "ZW", @@ -2156,9 +1929,7 @@ pub const ZW: CountryCode = CountryCode { numeric: 716, }; - - -///CountryCode map with alpha2 Code key +///CountryCode map with alpha2 Code key pub const ALPHA2_MAP: Map<&str, CountryCode> = phf_map! { @@ -2415,8 +2186,7 @@ pub const ALPHA2_MAP: Map<&str, CountryCode> = phf_map! { }; - -///CountryCode map with alpha3 Code key +///CountryCode map with alpha3 Code key pub const ALPHA3_MAP: Map<&str, CountryCode> = phf_map! { @@ -2673,8 +2443,7 @@ pub const ALPHA3_MAP: Map<&str, CountryCode> = phf_map! { }; - -///CountryCode map with 3 len numeric str Code key +///CountryCode map with 3 len numeric str Code key pub const NUMERIC_MAP: Map<&str, CountryCode> = phf_map! { @@ -2931,1551 +2700,355 @@ pub const NUMERIC_MAP: Map<&str, CountryCode> = phf_map! { }; - ///ALL the names of Countrys -pub const ALL_NAME: & [&str] = &[ - - -"Afghanistan", -"Åland Islands", -"Albania", -"Algeria", -"American Samoa", -"Andorra", -"Angola", -"Anguilla", -"Antarctica", -"Antigua and Barbuda", -"Argentina", -"Armenia", -"Aruba", -"Australia", -"Austria", -"Azerbaijan", -"Bahamas", -"Bahrain", -"Bangladesh", -"Barbados", -"Belarus", -"Belgium", -"Belize", -"Benin", -"Bermuda", -"Bhutan", -"Bolivia (Plurinational State of)", -"Bonaire, Sint Eustatius and Saba[c]", -"Bosnia and Herzegovina", -"Botswana", -"Bouvet Island", -"Brazil", -"British Indian Ocean Territory", -"Brunei Darussalam", -"Bulgaria", -"Burkina Faso", -"Burundi", -"Cabo Verde", -"Cambodia", -"Cameroon", -"Canada", -"Cayman Islands", -"Central African Republic", -"Chad", -"Chile", -"China", -"Christmas Island", -"Cocos (Keeling) Islands", -"Colombia", -"Comoros", -"Congo", -"Congo, Democratic Republic of the", -"Cook Islands", -"Costa Rica", -"Côte d'Ivoire", -"Croatia", -"Cuba", -"Curaçao", -"Cyprus", -"Czechia", -"Denmark", -"Djibouti", -"Dominica", -"Dominican Republic", -"Ecuador", -"Egypt", -"El Salvador", -"Equatorial Guinea", -"Eritrea", -"Estonia", -"Eswatini", -"Ethiopia", -"Falkland Islands (Malvinas)", -"Faroe Islands", -"Fiji", -"Finland", -"France", -"French Guiana", -"French Polynesia", -"French Southern Territories", -"Gabon", -"Gambia", -"Georgia", -"Germany", -"Ghana", -"Gibraltar", -"Greece", -"Greenland", -"Grenada", -"Guadeloupe", -"Guam", -"Guatemala", -"Guernsey", -"Guinea", -"Guinea-Bissau", -"Guyana", -"Haiti", -"Heard Island and McDonald Islands", -"Holy See", -"Honduras", -"Hong Kong", -"Hungary", -"Iceland", -"India", -"Indonesia", -"Iran (Islamic Republic of)", -"Iraq", -"Ireland", -"Isle of Man", -"Israel", -"Italy", -"Jamaica", -"Japan", -"Jersey", -"Jordan", -"Kazakhstan", -"Kenya", -"Kiribati", -"Korea (Democratic People's Republic of)", -"Korea, Republic of", -"Kuwait", -"Kyrgyzstan", -"Lao People's Democratic Republic", -"Latvia", -"Lebanon", -"Lesotho", -"Liberia", -"Libya", -"Liechtenstein", -"Lithuania", -"Luxembourg", -"Macao", -"Madagascar", -"Malawi", -"Malaysia", -"Maldives", -"Mali", -"Malta", -"Marshall Islands", -"Martinique", -"Mauritania", -"Mauritius", -"Mayotte", -"Mexico", -"Micronesia (Federated States of)", -"Moldova, Republic of", -"Monaco", -"Mongolia", -"Montenegro", -"Montserrat", -"Morocco", -"Mozambique", -"Myanmar", -"Namibia", -"Nauru", -"Nepal", -"Netherlands", -"New Caledonia", -"New Zealand", -"Nicaragua", -"Niger", -"Nigeria", -"Niue", -"Norfolk Island", -"North Macedonia", -"Northern Mariana Islands", -"Norway", -"Oman", -"Pakistan", -"Palau", -"Palestine, State of", -"Panama", -"Papua New Guinea", -"Paraguay", -"Peru", -"Philippines", -"Pitcairn", -"Poland", -"Portugal", -"Puerto Rico", -"Qatar", -"Réunion", -"Romania", -"Russian Federation", -"Rwanda", -"Saint Barthélemy", -"Saint Helena, Ascension and Tristan da Cunha[d]", -"Saint Kitts and Nevis", -"Saint Lucia", -"Saint Martin (French part)", -"Saint Pierre and Miquelon", -"Saint Vincent and the Grenadines", -"Samoa", -"San Marino", -"Sao Tome and Principe", -"Saudi Arabia", -"Senegal", -"Serbia", -"Seychelles", -"Sierra Leone", -"Singapore", -"Sint Maarten (Dutch part)", -"Slovakia", -"Slovenia", -"Solomon Islands", -"Somalia", -"South Africa", -"South Georgia and the South Sandwich Islands", -"South Sudan", -"Spain", -"Sri Lanka", -"Sudan", -"Suriname", -"Svalbard and Jan Mayen[e]", -"Sweden", -"Switzerland", -"Syrian Arab Republic", -"Taiwan, Province of China", -"Tajikistan", -"Tanzania, United Republic of", -"Thailand", -"Timor-Leste", -"Togo", -"Tokelau", -"Tonga", -"Trinidad and Tobago", -"Tunisia", -"Turkey", -"Turkmenistan", -"Turks and Caicos Islands", -"Tuvalu", -"Uganda", -"Ukraine", -"United Arab Emirates", -"United Kingdom of Great Britain and Northern Ireland", -"United States of America", -"United States Minor Outlying Islands[f]", -"Uruguay", -"Uzbekistan", -"Vanuatu", -"Venezuela (Bolivarian Republic of)", -"Viet Nam", -"Virgin Islands (British)", -"Virgin Islands (U.S.)", -"Wallis and Futuna", -"Western Sahara", -"Yemen", -"Zambia", -"Zimbabwe", - - +pub const ALL_NAME: &[&str] = &[ + "Afghanistan", + "Åland Islands", + "Albania", + "Algeria", + "American Samoa", + "Andorra", + "Angola", + "Anguilla", + "Antarctica", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Aruba", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia (Plurinational State of)", + "Bonaire, Sint Eustatius and Saba[c]", + "Bosnia and Herzegovina", + "Botswana", + "Bouvet Island", + "Brazil", + "British Indian Ocean Territory", + "Brunei Darussalam", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Cabo Verde", + "Cambodia", + "Cameroon", + "Canada", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Christmas Island", + "Cocos (Keeling) Islands", + "Colombia", + "Comoros", + "Congo", + "Congo, Democratic Republic of the", + "Cook Islands", + "Costa Rica", + "Côte d'Ivoire", + "Croatia", + "Cuba", + "Curaçao", + "Cyprus", + "Czechia", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Eswatini", + "Ethiopia", + "Falkland Islands (Malvinas)", + "Faroe Islands", + "Fiji", + "Finland", + "France", + "French Guiana", + "French Polynesia", + "French Southern Territories", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guam", + "Guatemala", + "Guernsey", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Heard Island and McDonald Islands", + "Holy See", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran (Islamic Republic of)", + "Iraq", + "Ireland", + "Isle of Man", + "Israel", + "Italy", + "Jamaica", + "Japan", + "Jersey", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Korea (Democratic People's Republic of)", + "Korea, Republic of", + "Kuwait", + "Kyrgyzstan", + "Lao People's Democratic Republic", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Martinique", + "Mauritania", + "Mauritius", + "Mayotte", + "Mexico", + "Micronesia (Federated States of)", + "Moldova, Republic of", + "Monaco", + "Mongolia", + "Montenegro", + "Montserrat", + "Morocco", + "Mozambique", + "Myanmar", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "Niue", + "Norfolk Island", + "North Macedonia", + "Northern Mariana Islands", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestine, State of", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Pitcairn", + "Poland", + "Portugal", + "Puerto Rico", + "Qatar", + "Réunion", + "Romania", + "Russian Federation", + "Rwanda", + "Saint Barthélemy", + "Saint Helena, Ascension and Tristan da Cunha[d]", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Martin (French part)", + "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Senegal", + "Serbia", + "Seychelles", + "Sierra Leone", + "Singapore", + "Sint Maarten (Dutch part)", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Georgia and the South Sandwich Islands", + "South Sudan", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Svalbard and Jan Mayen[e]", + "Sweden", + "Switzerland", + "Syrian Arab Republic", + "Taiwan, Province of China", + "Tajikistan", + "Tanzania, United Republic of", + "Thailand", + "Timor-Leste", + "Togo", + "Tokelau", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Turks and Caicos Islands", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom of Great Britain and Northern Ireland", + "United States of America", + "United States Minor Outlying Islands[f]", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela (Bolivarian Republic of)", + "Viet Nam", + "Virgin Islands (British)", + "Virgin Islands (U.S.)", + "Wallis and Futuna", + "Western Sahara", + "Yemen", + "Zambia", + "Zimbabwe", ]; - ///ALL the alpha2 codes of Countrys -pub const ALL_ALPHA2: & [&str] = &[ - - -"AF", -"AX", -"AL", -"DZ", -"AS", -"AD", -"AO", -"AI", -"AQ", -"AG", -"AR", -"AM", -"AW", -"AU", -"AT", -"AZ", -"BS", -"BH", -"BD", -"BB", -"BY", -"BE", -"BZ", -"BJ", -"BM", -"BT", -"BO", -"BQ", -"BA", -"BW", -"BV", -"BR", -"IO", -"BN", -"BG", -"BF", -"BI", -"CV", -"KH", -"CM", -"CA", -"KY", -"CF", -"TD", -"CL", -"CN", -"CX", -"CC", -"CO", -"KM", -"CG", -"CD", -"CK", -"CR", -"CI", -"HR", -"CU", -"CW", -"CY", -"CZ", -"DK", -"DJ", -"DM", -"DO", -"EC", -"EG", -"SV", -"GQ", -"ER", -"EE", -"SZ", -"ET", -"FK", -"FO", -"FJ", -"FI", -"FR", -"GF", -"PF", -"TF", -"GA", -"GM", -"GE", -"DE", -"GH", -"GI", -"GR", -"GL", -"GD", -"GP", -"GU", -"GT", -"GG", -"GN", -"GW", -"GY", -"HT", -"HM", -"VA", -"HN", -"HK", -"HU", -"IS", -"IN", -"ID", -"IR", -"IQ", -"IE", -"IM", -"IL", -"IT", -"JM", -"JP", -"JE", -"JO", -"KZ", -"KE", -"KI", -"KP", -"KR", -"KW", -"KG", -"LA", -"LV", -"LB", -"LS", -"LR", -"LY", -"LI", -"LT", -"LU", -"MO", -"MG", -"MW", -"MY", -"MV", -"ML", -"MT", -"MH", -"MQ", -"MR", -"MU", -"YT", -"MX", -"FM", -"MD", -"MC", -"MN", -"ME", -"MS", -"MA", -"MZ", -"MM", -"NA", -"NR", -"NP", -"NL", -"NC", -"NZ", -"NI", -"NE", -"NG", -"NU", -"NF", -"MK", -"MP", -"NO", -"OM", -"PK", -"PW", -"PS", -"PA", -"PG", -"PY", -"PE", -"PH", -"PN", -"PL", -"PT", -"PR", -"QA", -"RE", -"RO", -"RU", -"RW", -"BL", -"SH", -"KN", -"LC", -"MF", -"PM", -"VC", -"WS", -"SM", -"ST", -"SA", -"SN", -"RS", -"SC", -"SL", -"SG", -"SX", -"SK", -"SI", -"SB", -"SO", -"ZA", -"GS", -"SS", -"ES", -"LK", -"SD", -"SR", -"SJ", -"SE", -"CH", -"SY", -"TW", -"TJ", -"TZ", -"TH", -"TL", -"TG", -"TK", -"TO", -"TT", -"TN", -"TR", -"TM", -"TC", -"TV", -"UG", -"UA", -"AE", -"GB", -"US", -"UM", -"UY", -"UZ", -"VU", -"VE", -"VN", -"VG", -"VI", -"WF", -"EH", -"YE", -"ZM", -"ZW", - - +pub const ALL_ALPHA2: &[&str] = &[ + "AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", + "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", + "IO", "BN", "BG", "BF", "BI", "CV", "KH", "CM", "CA", "KY", "CF", "TD", "CL", "CN", "CX", "CC", + "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", + "EC", "EG", "SV", "GQ", "ER", "EE", "SZ", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", + "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", + "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", + "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", + "LI", "LT", "LU", "MO", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", + "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", + "NE", "NG", "NU", "NF", "MK", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", + "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", + "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", + "SS", "ES", "LK", "SD", "SR", "SJ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", + "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", + "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW", ]; - ///ALL the alpha3 codes of Countrys -pub const ALL_ALPHA3: & [&str] = &[ - - -"AFG", -"ALA", -"ALB", -"DZA", -"ASM", -"AND", -"AGO", -"AIA", -"ATA", -"ATG", -"ARG", -"ARM", -"ABW", -"AUS", -"AUT", -"AZE", -"BHS", -"BHR", -"BGD", -"BRB", -"BLR", -"BEL", -"BLZ", -"BEN", -"BMU", -"BTN", -"BOL", -"BES", -"BIH", -"BWA", -"BVT", -"BRA", -"IOT", -"BRN", -"BGR", -"BFA", -"BDI", -"CPV", -"KHM", -"CMR", -"CAN", -"CYM", -"CAF", -"TCD", -"CHL", -"CHN", -"CXR", -"CCK", -"COL", -"COM", -"COG", -"COD", -"COK", -"CRI", -"CIV", -"HRV", -"CUB", -"CUW", -"CYP", -"CZE", -"DNK", -"DJI", -"DMA", -"DOM", -"ECU", -"EGY", -"SLV", -"GNQ", -"ERI", -"EST", -"SWZ", -"ETH", -"FLK", -"FRO", -"FJI", -"FIN", -"FRA", -"GUF", -"PYF", -"ATF", -"GAB", -"GMB", -"GEO", -"DEU", -"GHA", -"GIB", -"GRC", -"GRL", -"GRD", -"GLP", -"GUM", -"GTM", -"GGY", -"GIN", -"GNB", -"GUY", -"HTI", -"HMD", -"VAT", -"HND", -"HKG", -"HUN", -"ISL", -"IND", -"IDN", -"IRN", -"IRQ", -"IRL", -"IMN", -"ISR", -"ITA", -"JAM", -"JPN", -"JEY", -"JOR", -"KAZ", -"KEN", -"KIR", -"PRK", -"KOR", -"KWT", -"KGZ", -"LAO", -"LVA", -"LBN", -"LSO", -"LBR", -"LBY", -"LIE", -"LTU", -"LUX", -"MAC", -"MDG", -"MWI", -"MYS", -"MDV", -"MLI", -"MLT", -"MHL", -"MTQ", -"MRT", -"MUS", -"MYT", -"MEX", -"FSM", -"MDA", -"MCO", -"MNG", -"MNE", -"MSR", -"MAR", -"MOZ", -"MMR", -"NAM", -"NRU", -"NPL", -"NLD", -"NCL", -"NZL", -"NIC", -"NER", -"NGA", -"NIU", -"NFK", -"MKD", -"MNP", -"NOR", -"OMN", -"PAK", -"PLW", -"PSE", -"PAN", -"PNG", -"PRY", -"PER", -"PHL", -"PCN", -"POL", -"PRT", -"PRI", -"QAT", -"REU", -"ROU", -"RUS", -"RWA", -"BLM", -"SHN", -"KNA", -"LCA", -"MAF", -"SPM", -"VCT", -"WSM", -"SMR", -"STP", -"SAU", -"SEN", -"SRB", -"SYC", -"SLE", -"SGP", -"SXM", -"SVK", -"SVN", -"SLB", -"SOM", -"ZAF", -"SGS", -"SSD", -"ESP", -"LKA", -"SDN", -"SUR", -"SJM", -"SWE", -"CHE", -"SYR", -"TWN", -"TJK", -"TZA", -"THA", -"TLS", -"TGO", -"TKL", -"TON", -"TTO", -"TUN", -"TUR", -"TKM", -"TCA", -"TUV", -"UGA", -"UKR", -"ARE", -"GBR", -"USA", -"UMI", -"URY", -"UZB", -"VUT", -"VEN", -"VNM", -"VGB", -"VIR", -"WLF", -"ESH", -"YEM", -"ZMB", -"ZWE", - - +pub const ALL_ALPHA3: &[&str] = &[ + "AFG", "ALA", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATA", "ATG", "ARG", "ARM", "ABW", + "AUS", "AUT", "AZE", "BHS", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", + "BOL", "BES", "BIH", "BWA", "BVT", "BRA", "IOT", "BRN", "BGR", "BFA", "BDI", "CPV", "KHM", + "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "CXR", "CCK", "COL", "COM", "COG", "COD", + "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", + "EGY", "SLV", "GNQ", "ERI", "EST", "SWZ", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "GUF", + "PYF", "ATF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GLP", "GUM", + "GTM", "GGY", "GIN", "GNB", "GUY", "HTI", "HMD", "VAT", "HND", "HKG", "HUN", "ISL", "IND", + "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", + "KIR", "PRK", "KOR", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", + "LUX", "MAC", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MTQ", "MRT", "MUS", "MYT", + "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MSR", "MAR", "MOZ", "MMR", "NAM", "NRU", "NPL", + "NLD", "NCL", "NZL", "NIC", "NER", "NGA", "NIU", "NFK", "MKD", "MNP", "NOR", "OMN", "PAK", + "PLW", "PSE", "PAN", "PNG", "PRY", "PER", "PHL", "PCN", "POL", "PRT", "PRI", "QAT", "REU", + "ROU", "RUS", "RWA", "BLM", "SHN", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", + "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SGS", + "SSD", "ESP", "LKA", "SDN", "SUR", "SJM", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", + "TLS", "TGO", "TKL", "TON", "TTO", "TUN", "TUR", "TKM", "TCA", "TUV", "UGA", "UKR", "ARE", + "GBR", "USA", "UMI", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "VIR", "WLF", "ESH", "YEM", + "ZMB", "ZWE", ]; - ///ALL the 3 length numeric str codes of Countrys -pub const ALL_NUMERIC_STR: & [&str] = &[ - - -"004", -"248", -"008", -"012", -"016", -"020", -"024", -"660", -"010", -"028", -"032", -"051", -"533", -"036", -"040", -"031", -"044", -"048", -"050", -"052", -"112", -"056", -"084", -"204", -"060", -"064", -"068", -"535", -"070", -"072", -"074", -"076", -"086", -"096", -"100", -"854", -"108", -"132", -"116", -"120", -"124", -"136", -"140", -"148", -"152", -"156", -"162", -"166", -"170", -"174", -"178", -"180", -"184", -"188", -"384", -"191", -"192", -"531", -"196", -"203", -"208", -"262", -"212", -"214", -"218", -"818", -"222", -"226", -"232", -"233", -"748", -"231", -"238", -"234", -"242", -"246", -"250", -"254", -"258", -"260", -"266", -"270", -"268", -"276", -"288", -"292", -"300", -"304", -"308", -"312", -"316", -"320", -"831", -"324", -"624", -"328", -"332", -"334", -"336", -"340", -"344", -"348", -"352", -"356", -"360", -"364", -"368", -"372", -"833", -"376", -"380", -"388", -"392", -"832", -"400", -"398", -"404", -"296", -"408", -"410", -"414", -"417", -"418", -"428", -"422", -"426", -"430", -"434", -"438", -"440", -"442", -"446", -"450", -"454", -"458", -"462", -"466", -"470", -"584", -"474", -"478", -"480", -"175", -"484", -"583", -"498", -"492", -"496", -"499", -"500", -"504", -"508", -"104", -"516", -"520", -"524", -"528", -"540", -"554", -"558", -"562", -"566", -"570", -"574", -"807", -"580", -"578", -"512", -"586", -"585", -"275", -"591", -"598", -"600", -"604", -"608", -"612", -"616", -"620", -"630", -"634", -"638", -"642", -"643", -"646", -"652", -"654", -"659", -"662", -"663", -"666", -"670", -"882", -"674", -"678", -"682", -"686", -"688", -"690", -"694", -"702", -"534", -"703", -"705", -"090", -"706", -"710", -"239", -"728", -"724", -"144", -"729", -"740", -"744", -"752", -"756", -"760", -"158", -"762", -"834", -"764", -"626", -"768", -"772", -"776", -"780", -"788", -"792", -"795", -"796", -"798", -"800", -"804", -"784", -"826", -"840", -"581", -"858", -"860", -"548", -"862", -"704", -"092", -"850", -"876", -"732", -"887", -"894", -"716", - - +pub const ALL_NUMERIC_STR: &[&str] = &[ + "004", "248", "008", "012", "016", "020", "024", "660", "010", "028", "032", "051", "533", + "036", "040", "031", "044", "048", "050", "052", "112", "056", "084", "204", "060", "064", + "068", "535", "070", "072", "074", "076", "086", "096", "100", "854", "108", "132", "116", + "120", "124", "136", "140", "148", "152", "156", "162", "166", "170", "174", "178", "180", + "184", "188", "384", "191", "192", "531", "196", "203", "208", "262", "212", "214", "218", + "818", "222", "226", "232", "233", "748", "231", "238", "234", "242", "246", "250", "254", + "258", "260", "266", "270", "268", "276", "288", "292", "300", "304", "308", "312", "316", + "320", "831", "324", "624", "328", "332", "334", "336", "340", "344", "348", "352", "356", + "360", "364", "368", "372", "833", "376", "380", "388", "392", "832", "400", "398", "404", + "296", "408", "410", "414", "417", "418", "428", "422", "426", "430", "434", "438", "440", + "442", "446", "450", "454", "458", "462", "466", "470", "584", "474", "478", "480", "175", + "484", "583", "498", "492", "496", "499", "500", "504", "508", "104", "516", "520", "524", + "528", "540", "554", "558", "562", "566", "570", "574", "807", "580", "578", "512", "586", + "585", "275", "591", "598", "600", "604", "608", "612", "616", "620", "630", "634", "638", + "642", "643", "646", "652", "654", "659", "662", "663", "666", "670", "882", "674", "678", + "682", "686", "688", "690", "694", "702", "534", "703", "705", "090", "706", "710", "239", + "728", "724", "144", "729", "740", "744", "752", "756", "760", "158", "762", "834", "764", + "626", "768", "772", "776", "780", "788", "792", "795", "796", "798", "800", "804", "784", + "826", "840", "581", "858", "860", "548", "862", "704", "092", "850", "876", "732", "887", + "894", "716", ]; - ///ALL the numeric codes of Countrys -pub const ALL_NUMERIC: & [i32] = &[ - - -4, -248, -8, -12, -16, -20, -24, -660, -10, -28, -32, -51, -533, -36, -40, -31, -44, -48, -50, -52, -112, -56, -84, -204, -60, -64, -68, -535, -70, -72, -74, -76, -86, -96, -100, -854, -108, -132, -116, -120, -124, -136, -140, -148, -152, -156, -162, -166, -170, -174, -178, -180, -184, -188, -384, -191, -192, -531, -196, -203, -208, -262, -212, -214, -218, -818, -222, -226, -232, -233, -748, -231, -238, -234, -242, -246, -250, -254, -258, -260, -266, -270, -268, -276, -288, -292, -300, -304, -308, -312, -316, -320, -831, -324, -624, -328, -332, -334, -336, -340, -344, -348, -352, -356, -360, -364, -368, -372, -833, -376, -380, -388, -392, -832, -400, -398, -404, -296, -408, -410, -414, -417, -418, -428, -422, -426, -430, -434, -438, -440, -442, -446, -450, -454, -458, -462, -466, -470, -584, -474, -478, -480, -175, -484, -583, -498, -492, -496, -499, -500, -504, -508, -104, -516, -520, -524, -528, -540, -554, -558, -562, -566, -570, -574, -807, -580, -578, -512, -586, -585, -275, -591, -598, -600, -604, -608, -612, -616, -620, -630, -634, -638, -642, -643, -646, -652, -654, -659, -662, -663, -666, -670, -882, -674, -678, -682, -686, -688, -690, -694, -702, -534, -703, -705, -90, -706, -710, -239, -728, -724, -144, -729, -740, -744, -752, -756, -760, -158, -762, -834, -764, -626, -768, -772, -776, -780, -788, -792, -795, -796, -798, -800, -804, -784, -826, -840, -581, -858, -860, -548, -862, -704, -92, -850, -876, -732, -887, -894, -716, - - +pub const ALL_NUMERIC: &[i32] = &[ + 4, 248, 8, 12, 16, 20, 24, 660, 10, 28, 32, 51, 533, 36, 40, 31, 44, 48, 50, 52, 112, 56, 84, + 204, 60, 64, 68, 535, 70, 72, 74, 76, 86, 96, 100, 854, 108, 132, 116, 120, 124, 136, 140, 148, + 152, 156, 162, 166, 170, 174, 178, 180, 184, 188, 384, 191, 192, 531, 196, 203, 208, 262, 212, + 214, 218, 818, 222, 226, 232, 233, 748, 231, 238, 234, 242, 246, 250, 254, 258, 260, 266, 270, + 268, 276, 288, 292, 300, 304, 308, 312, 316, 320, 831, 324, 624, 328, 332, 334, 336, 340, 344, + 348, 352, 356, 360, 364, 368, 372, 833, 376, 380, 388, 392, 832, 400, 398, 404, 296, 408, 410, + 414, 417, 418, 428, 422, 426, 430, 434, 438, 440, 442, 446, 450, 454, 458, 462, 466, 470, 584, + 474, 478, 480, 175, 484, 583, 498, 492, 496, 499, 500, 504, 508, 104, 516, 520, 524, 528, 540, + 554, 558, 562, 566, 570, 574, 807, 580, 578, 512, 586, 585, 275, 591, 598, 600, 604, 608, 612, + 616, 620, 630, 634, 638, 642, 643, 646, 652, 654, 659, 662, 663, 666, 670, 882, 674, 678, 682, + 686, 688, 690, 694, 702, 534, 703, 705, 90, 706, 710, 239, 728, 724, 144, 729, 740, 744, 752, + 756, 760, 158, 762, 834, 764, 626, 768, 772, 776, 780, 788, 792, 795, 796, 798, 800, 804, 784, + 826, 840, 581, 858, 860, 548, 862, 704, 92, 850, 876, 732, 887, 894, 716, ]; - ///ALL the Countrys struct -pub const ALL: & [CountryCode] = &[ - - -AF, -AX, -AL, -DZ, -AS, -AD, -AO, -AI, -AQ, -AG, -AR, -AM, -AW, -AU, -AT, -AZ, -BS, -BH, -BD, -BB, -BY, -BE, -BZ, -BJ, -BM, -BT, -BO, -BQ, -BA, -BW, -BV, -BR, -IO, -BN, -BG, -BF, -BI, -CV, -KH, -CM, -CA, -KY, -CF, -TD, -CL, -CN, -CX, -CC, -CO, -KM, -CG, -CD, -CK, -CR, -CI, -HR, -CU, -CW, -CY, -CZ, -DK, -DJ, -DM, -DO, -EC, -EG, -SV, -GQ, -ER, -EE, -SZ, -ET, -FK, -FO, -FJ, -FI, -FR, -GF, -PF, -TF, -GA, -GM, -GE, -DE, -GH, -GI, -GR, -GL, -GD, -GP, -GU, -GT, -GG, -GN, -GW, -GY, -HT, -HM, -VA, -HN, -HK, -HU, -IS, -IN, -ID, -IR, -IQ, -IE, -IM, -IL, -IT, -JM, -JP, -JE, -JO, -KZ, -KE, -KI, -KP, -KR, -KW, -KG, -LA, -LV, -LB, -LS, -LR, -LY, -LI, -LT, -LU, -MO, -MG, -MW, -MY, -MV, -ML, -MT, -MH, -MQ, -MR, -MU, -YT, -MX, -FM, -MD, -MC, -MN, -ME, -MS, -MA, -MZ, -MM, -NA, -NR, -NP, -NL, -NC, -NZ, -NI, -NE, -NG, -NU, -NF, -MK, -MP, -NO, -OM, -PK, -PW, -PS, -PA, -PG, -PY, -PE, -PH, -PN, -PL, -PT, -PR, -QA, -RE, -RO, -RU, -RW, -BL, -SH, -KN, -LC, -MF, -PM, -VC, -WS, -SM, -ST, -SA, -SN, -RS, -SC, -SL, -SG, -SX, -SK, -SI, -SB, -SO, -ZA, -GS, -SS, -ES, -LK, -SD, -SR, -SJ, -SE, -CH, -SY, -TW, -TJ, -TZ, -TH, -TL, -TG, -TK, -TO, -TT, -TN, -TR, -TM, -TC, -TV, -UG, -UA, -AE, -GB, -US, -UM, -UY, -UZ, -VU, -VE, -VN, -VG, -VI, -WF, -EH, -YE, -ZM, -ZW, - - +pub const ALL: &[CountryCode] = &[ + AF, AX, AL, DZ, AS, AD, AO, AI, AQ, AG, AR, AM, AW, AU, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, + BM, BT, BO, BQ, BA, BW, BV, BR, IO, BN, BG, BF, BI, CV, KH, CM, CA, KY, CF, TD, CL, CN, CX, CC, + CO, KM, CG, CD, CK, CR, CI, HR, CU, CW, CY, CZ, DK, DJ, DM, DO, EC, EG, SV, GQ, ER, EE, SZ, ET, + FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GH, GI, GR, GL, GD, GP, GU, GT, GG, GN, GW, GY, + HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, KP, KR, + KW, KG, LA, LV, LB, LS, LR, LY, LI, LT, LU, MO, MG, MW, MY, MV, ML, MT, MH, MQ, MR, MU, YT, MX, + FM, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NL, NC, NZ, NI, NE, NG, NU, NF, MK, MP, NO, OM, + PK, PW, PS, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, RE, RO, RU, RW, BL, SH, KN, LC, MF, PM, VC, + WS, SM, ST, SA, SN, RS, SC, SL, SG, SX, SK, SI, SB, SO, ZA, GS, SS, ES, LK, SD, SR, SJ, SE, CH, + SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, UG, UA, AE, GB, US, UM, UY, UZ, VU, + VE, VN, VG, VI, WF, EH, YE, ZM, ZW, ]; - diff --git a/tests/test_serde.rs b/tests/test_serde.rs new file mode 100644 index 0000000..fd91d74 --- /dev/null +++ b/tests/test_serde.rs @@ -0,0 +1,151 @@ +#[cfg(feature = "serde")] +mod tests { + extern crate serde_json; + + use rust_iso3166::iso3166_2::from_code as from_code_2; + use rust_iso3166::iso3166_3::from_code as from_code_3; + use rust_iso3166::{from_alpha2, from_alpha3}; + + #[test] + fn test_country_code_serde() { + let au = from_alpha2("AU").unwrap(); + let au_json = serde_json::to_string(&au).unwrap(); + assert_eq!(au_json, "\"AU\""); + + let us = from_alpha3("USA").unwrap(); + let us_json = serde_json::to_string(&us).unwrap(); + assert_eq!(us_json, "\"US\""); + + let au_deserialized: rust_iso3166::CountryCode = serde_json::from_str("\"AU\"").unwrap(); + assert_eq!(au_deserialized.alpha2, "AU"); + assert_eq!(au_deserialized.alpha3, "AUS"); + + let us_deserialized: rust_iso3166::CountryCode = serde_json::from_str("\"USA\"").unwrap(); + assert_eq!(us_deserialized.alpha2, "US"); + assert_eq!(us_deserialized.alpha3, "USA"); + } + + #[test] + fn test_subdivision_serde() { + let gb_edh = from_code_2("GB-EDH").unwrap(); + let gb_edh_json = serde_json::to_string(&gb_edh).unwrap(); + assert_eq!(gb_edh_json, "\"GB-EDH\""); + + let gb_edh_deserialized: rust_iso3166::iso3166_2::Subdivision = + serde_json::from_str("\"GB-EDH\"").unwrap(); + assert_eq!(gb_edh_deserialized.code, "GB-EDH"); + assert_eq!(gb_edh_deserialized.name, "Edinburgh, City of"); + } + + #[test] + fn test_country_code3_serde() { + let pzpa = from_code_3("PZPA").unwrap(); + let pzpa_json = serde_json::to_string(&pzpa).unwrap(); + assert_eq!(pzpa_json, "\"PZPA\""); + + let pzpa_deserialized: rust_iso3166::iso3166_3::CountryCode3 = + serde_json::from_str("\"PZPA\"").unwrap(); + assert_eq!(pzpa_deserialized.code, "PZPA"); + assert_eq!(pzpa_deserialized.name, "Panama Canal Zone"); + } + + #[test] + fn test_country_code_case_insensitive() { + let au_lower: rust_iso3166::CountryCode = serde_json::from_str("\"au\"").unwrap(); + assert_eq!(au_lower.alpha2, "AU"); + assert_eq!(au_lower.alpha3, "AUS"); + + let us_mixed: rust_iso3166::CountryCode = serde_json::from_str("\"uSa\"").unwrap(); + assert_eq!(us_mixed.alpha2, "US"); + assert_eq!(us_mixed.alpha3, "USA"); + + let gb_upper: rust_iso3166::CountryCode = serde_json::from_str("\"GB\"").unwrap(); + assert_eq!(gb_upper.alpha2, "GB"); + assert_eq!(gb_upper.alpha3, "GBR"); + } + + #[test] + fn test_subdivision_case_insensitive() { + let gb_edh_lower: rust_iso3166::iso3166_2::Subdivision = + serde_json::from_str("\"gb-edh\"").unwrap(); + assert_eq!(gb_edh_lower.code, "GB-EDH"); + assert_eq!(gb_edh_lower.name, "Edinburgh, City of"); + + let gb_edh_mixed: rust_iso3166::iso3166_2::Subdivision = + serde_json::from_str("\"Gb-Edh\"").unwrap(); + assert_eq!(gb_edh_mixed.code, "GB-EDH"); + assert_eq!(gb_edh_mixed.name, "Edinburgh, City of"); + } + + #[test] + fn test_country_code3_case_insensitive() { + let pzpa_lower: rust_iso3166::iso3166_3::CountryCode3 = + serde_json::from_str("\"pzpa\"").unwrap(); + assert_eq!(pzpa_lower.code, "PZPA"); + assert_eq!(pzpa_lower.name, "Panama Canal Zone"); + + let pzpa_mixed: rust_iso3166::iso3166_3::CountryCode3 = + serde_json::from_str("\"PzPa\"").unwrap(); + assert_eq!(pzpa_mixed.code, "PZPA"); + assert_eq!(pzpa_mixed.name, "Panama Canal Zone"); + } + + #[test] + fn test_invalid_country_code() { + let result: Result = serde_json::from_str("\"XX\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"XXX\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"1234\""); + assert!(result.is_err()); + } + + #[test] + fn test_invalid_subdivision() { + let result: Result = + serde_json::from_str("\"XX-XX\""); + assert!(result.is_err()); + + let result: Result = + serde_json::from_str("\"GB-XXX\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"\""); + assert!(result.is_err()); + } + + #[test] + fn test_invalid_country_code3() { + let result: Result = + serde_json::from_str("\"XXXX\""); + assert!(result.is_err()); + + let result: Result = + serde_json::from_str("\"XXX\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"\""); + assert!(result.is_err()); + } + + #[test] + fn test_boundary_cases() { + let result: Result = serde_json::from_str("\"036\""); + assert!(result.is_err()); // Direct deserialization of numeric codes is not currently supported + + let result: Result = serde_json::from_str("\"A@\""); + assert!(result.is_err()); + + let result: Result = serde_json::from_str("\"🫡❤️\""); + assert!(result.is_err()); + + let result: Result = + serde_json::from_str("\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\""); + assert!(result.is_err()); + } +}