use crate::error::Error as GoogleMapsError;
use phf::phf_map;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(u16)]
#[non_exhaustive]
pub enum Country {
Afghanistan = 0,
AlandIslands = 1,
Albania = 2,
Algeria = 3,
AmericanSamoa = 4,
Andorra = 5,
Angola = 6,
Anguilla = 7,
Antarctica = 8,
AntiguaAndBarbuda = 9,
Argentina = 10,
Armenia = 11,
Aruba = 12,
Australia = 13,
Austria = 14,
Azerbaijan = 15,
Bahamas = 16,
Bahrain = 17,
Bangladesh = 18,
Barbados = 19,
Belarus = 20,
Belgium = 21,
Belize = 22,
Benin = 23,
Bermuda = 24,
Bhutan = 25,
Bolivia = 26,
BonaireSintEustatiusAndSaba = 27,
BosniaAndHerzegovina = 28,
Botswana = 29,
BouvetIsland = 30,
Brazil = 31,
BritishIndianOceanTerritory = 32,
BritishVirginIslands = 33,
Brunei = 34,
Bulgaria = 35,
BurkinaFaso = 36,
Burundi = 37,
CaboVerde = 38,
Cambodia = 39,
Cameroon = 40,
Canada = 41,
CaymanIslands = 42,
CentralAfricanRepublic = 43,
Chad = 44,
Chile = 45,
China = 46,
ChristmasIsland = 47,
CocosKeelingIslands = 48,
Colombia = 49,
Comoros = 50,
CongoBraXXaville = 51,
CongoKinshasa = 52,
CookIslands = 53,
CostaRica = 54,
CotedIvoire = 55,
Croatia = 56,
Cuba = 57,
Curacao = 58,
Cyprus = 59,
Czechia = 60,
Denmark = 61,
Djibouti = 62,
Dominica = 63,
DominicanRepublic = 64,
Ecuador = 65,
Egypt = 66,
ElSalvador = 67,
EquatorialGuinea = 68,
Eritrea = 69,
Estonia = 70,
Eswatini = 71,
Ethiopia = 72,
FalklandIslands = 73,
FaroeIslands = 74,
Fiji = 75,
Finland = 76,
France = 77,
FrenchGuiana = 78,
FrenchPolynesia = 79,
FrenchSouthernTerritories = 80,
Gabon = 81,
Gambia = 82,
Georgia = 83,
Germany = 84,
Ghana = 85,
Gibraltar = 86,
Greece = 87,
Greenland = 88,
Grenada = 89,
Guadeloupe = 90,
Guam = 91,
Guatemala = 92,
Guernsey = 93,
Guinea = 94,
GuineaBissau = 95,
Guyana = 96,
Haiti = 97,
HeardAndMcDonaldIslands = 98,
HolySee = 99,
Honduras = 100,
HongKong = 101,
Hungary = 102,
Iceland = 103,
India = 104,
Indonesia = 105,
Iran = 106,
Iraq = 107,
Ireland = 108,
IsleOfMan = 109,
Israel = 110,
Italy = 111,
Jamaica = 112,
Japan = 113,
Jersey = 114,
Jordan = 115,
Kazakhstan = 116,
Kenya = 117,
Kiribati = 118,
Kuwait = 119,
Kyrgyzstan = 120,
Laos = 121,
Latvia = 122,
Lebanon = 123,
Lesotho = 124,
Liberia = 125,
Libya = 126,
Liechtenstein = 127,
Lithuania = 128,
Luxembourg = 129,
Macao = 130,
Madagascar = 131,
Malawi = 132,
Malaysia = 133,
Maldives = 134,
Mali = 135,
Malta = 136,
MarshallIslands = 137,
Martinique = 138,
Mauritania = 139,
Mauritius = 140,
Mayotte = 141,
Mexico = 142,
Micronesia = 143,
Moldova = 144,
Monaco = 145,
Mongolia = 146,
Montenegro = 147,
Montserrat = 148,
Morocco = 149,
Mozambique = 150,
Myanmar = 151,
Namibia = 152,
Nauru = 153,
Nepal = 154,
Netherlands = 155,
NewCaledonia = 156,
NewZealand = 157,
Nicaragua = 158,
Niger = 159,
Nigeria = 160,
Niue = 161,
NorfolkIsland = 162,
NorthernMarianaIslands = 163,
NorthKorea = 164,
NorthMacedonia = 165,
Norway = 166,
Oman = 167,
Pakistan = 168,
Palau = 169,
Palestine = 170,
Panama = 171,
PapuaNewGuinea = 172,
Paraguay = 173,
Peru = 174,
Philippines = 175,
Pitcairn = 176,
Poland = 177,
Portugal = 178,
PuertoRico = 179,
Qatar = 180,
Reunion = 181,
Romania = 182,
Russia = 183,
Rwanda = 184,
Samoa = 185,
SanMarino = 186,
SaoTomeAndPrincipe = 187,
SaudiArabia = 188,
Senegal = 189,
Serbia = 190,
Seychelles = 191,
SierraLeone = 192,
Singapore = 193,
SintMaarten = 194,
Slovakia = 195,
Slovenia = 196,
SolomonIslands = 197,
Somalia = 198,
SouthAfrica = 199,
SouthGeorgiaAndSouthSandwichIslands = 200,
SouthKorea = 201,
SouthSudan = 202,
Spain = 203,
SriLanka = 204,
StBarthelemy = 205,
StHelena = 206,
StKittsAndNevis = 207,
StLucia = 208,
StMartin = 209,
StPierreAndMiquelon = 210,
StVincentAndGrenadines = 211,
Sudan = 212,
Suriname = 213,
SvalbardAndJanMayen = 214,
Sweden = 215,
Switzerland = 216,
Syria = 217,
Taiwan = 218,
Tajikistan = 219,
Tanzania = 220,
Thailand = 221,
TimorLeste = 222,
Togo = 223,
Tokelau = 224,
Tonga = 225,
TrinidadAndTobago = 226,
Tunisia = 227,
Turkey = 228,
Turkmenistan = 229,
TurksAndCaicosIslands = 230,
Tuvalu = 231,
Uganda = 232,
Ukraine = 233,
UnitedArabEmirates = 234,
UnitedKingdom = 235,
#[default]
UnitedStates = 236,
UnitedStatesMinorOutlyingIslands = 237,
Uruguay = 238,
USVirginIslands = 239,
Uzbekistan = 240,
Vanuatu = 241,
Venezuela = 242,
Vietnam = 243,
WallisAndFutuna = 244,
WesternSahara = 245,
Yemen = 246,
Zambia = 247,
Zimbabwe = 248,
Other = 249,
}
impl<'de> Deserialize<'de> for Country {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let string = String::deserialize(deserializer)?;
match Self::try_from(string.as_str()) {
Ok(variant) => Ok(variant),
Err(error) => Err(serde::de::Error::custom(error.to_string())),
} } }
impl Serialize for Country {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(std::convert::Into::<&str>::into(self))
} }
impl std::convert::From<&Self> for Country {
fn from(country: &Self) -> Self {
*country
} }
impl std::convert::From<&Country> for &str {
fn from(country: &Country) -> Self {
match country {
Country::Afghanistan => "AF",
Country::AlandIslands => "AX",
Country::Albania => "AL",
Country::Algeria => "DZ",
Country::AmericanSamoa => "AS",
Country::Andorra => "AD",
Country::Angola => "AO",
Country::Anguilla => "AI",
Country::Antarctica => "AQ",
Country::AntiguaAndBarbuda => "AG",
Country::Argentina => "AR",
Country::Armenia => "AM",
Country::Aruba => "AW",
Country::Australia => "AU",
Country::Austria => "AT",
Country::Azerbaijan => "AZ",
Country::Bahamas => "BS",
Country::Bahrain => "BH",
Country::Bangladesh => "BD",
Country::Barbados => "BB",
Country::Belarus => "BY",
Country::Belgium => "BE",
Country::Belize => "BZ",
Country::Benin => "BJ",
Country::Bermuda => "BM",
Country::Bhutan => "BT",
Country::Bolivia => "BO",
Country::BonaireSintEustatiusAndSaba => "BQ",
Country::BosniaAndHerzegovina => "BA",
Country::Botswana => "BW",
Country::BouvetIsland => "BV",
Country::Brazil => "BR",
Country::BritishIndianOceanTerritory => "IO",
Country::BritishVirginIslands => "VG",
Country::Brunei => "BN",
Country::Bulgaria => "BG",
Country::BurkinaFaso => "BF",
Country::Burundi => "BI",
Country::CaboVerde => "CV",
Country::Cambodia => "KH",
Country::Cameroon => "CM",
Country::Canada => "CA",
Country::CaymanIslands => "KY",
Country::CentralAfricanRepublic => "CF",
Country::Chad => "TD",
Country::Chile => "CL",
Country::China => "CN",
Country::ChristmasIsland => "CX",
Country::CocosKeelingIslands => "CC",
Country::Colombia => "CO",
Country::Comoros => "KM",
Country::CongoBraXXaville => "CG",
Country::CongoKinshasa => "CD",
Country::CookIslands => "CK",
Country::CostaRica => "CR",
Country::CotedIvoire => "CI",
Country::Croatia => "HR",
Country::Cuba => "CU",
Country::Curacao => "CW",
Country::Cyprus => "CY",
Country::Czechia => "CZ",
Country::Denmark => "DK",
Country::Djibouti => "DJ",
Country::Dominica => "DM",
Country::DominicanRepublic => "DO",
Country::Ecuador => "EC",
Country::Egypt => "EG",
Country::ElSalvador => "SV",
Country::EquatorialGuinea => "GQ",
Country::Eritrea => "ER",
Country::Estonia => "EE",
Country::Eswatini => "SZ",
Country::Ethiopia => "ET",
Country::FalklandIslands => "FK",
Country::FaroeIslands => "FO",
Country::Fiji => "FJ",
Country::Finland => "FI",
Country::France => "FR",
Country::FrenchGuiana => "GF",
Country::FrenchPolynesia => "PF",
Country::FrenchSouthernTerritories => "TF",
Country::Gabon => "GA",
Country::Gambia => "GM",
Country::Georgia => "GE",
Country::Germany => "DE",
Country::Ghana => "GH",
Country::Gibraltar => "GI",
Country::Greece => "GR",
Country::Greenland => "GL",
Country::Grenada => "GD",
Country::Guadeloupe => "GP",
Country::Guam => "GU",
Country::Guatemala => "GT",
Country::Guernsey => "GG",
Country::Guinea => "GN",
Country::GuineaBissau => "GW",
Country::Guyana => "GY",
Country::Haiti => "HT",
Country::HeardAndMcDonaldIslands => "HM",
Country::HolySee => "VA",
Country::Honduras => "HN",
Country::HongKong => "HK",
Country::Hungary => "HU",
Country::Iceland => "IS",
Country::India => "IN",
Country::Indonesia => "ID",
Country::Iran => "IR",
Country::Iraq => "IQ",
Country::Ireland => "IE",
Country::IsleOfMan => "IM",
Country::Israel => "IL",
Country::Italy => "IT",
Country::Jamaica => "JM",
Country::Japan => "JP",
Country::Jersey => "JE",
Country::Jordan => "JO",
Country::Kazakhstan => "KZ",
Country::Kenya => "KE",
Country::Kiribati => "KI",
Country::Kuwait => "KW",
Country::Kyrgyzstan => "KG",
Country::Laos => "LA",
Country::Latvia => "LV",
Country::Lebanon => "LB",
Country::Lesotho => "LS",
Country::Liberia => "LR",
Country::Libya => "LY",
Country::Liechtenstein => "LI",
Country::Lithuania => "LT",
Country::Luxembourg => "LU",
Country::Macao => "MO",
Country::Madagascar => "MG",
Country::Malawi => "MW",
Country::Malaysia => "MY",
Country::Maldives => "MV",
Country::Mali => "ML",
Country::Malta => "MT",
Country::MarshallIslands => "MH",
Country::Martinique => "MQ",
Country::Mauritania => "MR",
Country::Mauritius => "MU",
Country::Mayotte => "YT",
Country::Mexico => "MX",
Country::Micronesia => "FM",
Country::Moldova => "MD",
Country::Monaco => "MC",
Country::Mongolia => "MN",
Country::Montenegro => "ME",
Country::Montserrat => "MS",
Country::Morocco => "MA",
Country::Mozambique => "MZ",
Country::Myanmar => "MM",
Country::Namibia => "NA",
Country::Nauru => "NR",
Country::Nepal => "NP",
Country::Netherlands => "NL",
Country::NewCaledonia => "NC",
Country::NewZealand => "NZ",
Country::Nicaragua => "NI",
Country::Niger => "NE",
Country::Nigeria => "NG",
Country::Niue => "NU",
Country::NorfolkIsland => "NF",
Country::NorthernMarianaIslands => "MP",
Country::NorthKorea => "KP",
Country::NorthMacedonia => "MK",
Country::Norway => "NO",
Country::Oman => "OM",
Country::Pakistan => "PK",
Country::Palau => "PW",
Country::Palestine => "PS",
Country::Panama => "PA",
Country::PapuaNewGuinea => "PG",
Country::Paraguay => "PY",
Country::Peru => "PE",
Country::Philippines => "PH",
Country::Pitcairn => "PN",
Country::Poland => "PL",
Country::Portugal => "PT",
Country::PuertoRico => "PR",
Country::Qatar => "QA",
Country::Reunion => "RE",
Country::Romania => "RO",
Country::Russia => "RU",
Country::Rwanda => "RW",
Country::Samoa => "WS",
Country::SanMarino => "SM",
Country::SaoTomeAndPrincipe => "ST",
Country::SaudiArabia => "SA",
Country::Senegal => "SN",
Country::Serbia => "RS",
Country::Seychelles => "SC",
Country::SierraLeone => "SL",
Country::Singapore => "SG",
Country::SintMaarten => "SX",
Country::Slovakia => "SK",
Country::Slovenia => "SI",
Country::SolomonIslands => "SB",
Country::Somalia => "SO",
Country::SouthAfrica => "ZA",
Country::SouthGeorgiaAndSouthSandwichIslands => "GS",
Country::SouthKorea => "KR",
Country::SouthSudan => "SS",
Country::Spain => "ES",
Country::SriLanka => "LK",
Country::StBarthelemy => "BL",
Country::StHelena => "SH",
Country::StKittsAndNevis => "KN",
Country::StLucia => "LC",
Country::StMartin => "MF",
Country::StPierreAndMiquelon => "PM",
Country::StVincentAndGrenadines => "VC",
Country::Sudan => "SD",
Country::Suriname => "SR",
Country::SvalbardAndJanMayen => "SJ",
Country::Sweden => "SE",
Country::Switzerland => "CH",
Country::Syria => "SY",
Country::Taiwan => "TW",
Country::Tajikistan => "TJ",
Country::Tanzania => "TZ",
Country::Thailand => "TH",
Country::TimorLeste => "TL",
Country::Togo => "TG",
Country::Tokelau => "TK",
Country::Tonga => "TO",
Country::TrinidadAndTobago => "TT",
Country::Tunisia => "TN",
Country::Turkey => "TR",
Country::Turkmenistan => "TM",
Country::TurksAndCaicosIslands => "TC",
Country::Tuvalu => "TV",
Country::Uganda => "UG",
Country::Ukraine => "UA",
Country::UnitedArabEmirates => "AE",
Country::UnitedKingdom => "GB",
Country::UnitedStates => "US",
Country::UnitedStatesMinorOutlyingIslands => "UM",
Country::Uruguay => "UY",
Country::USVirginIslands => "VI",
Country::Uzbekistan => "UZ",
Country::Vanuatu => "VU",
Country::Venezuela => "VE",
Country::Vietnam => "VN",
Country::WallisAndFutuna => "WF",
Country::WesternSahara => "EH",
Country::Yemen => "YE",
Country::Zambia => "ZM",
Country::Zimbabwe => "ZW",
Country::Other => "XX",
} } }
impl std::fmt::Display for Country {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", std::convert::Into::<&str>::into(self))
} }
impl std::convert::From<&Country> for String {
fn from(country: &Country) -> Self {
std::convert::Into::<&str>::into(country).to_string()
} }
static COUNTRIES_BY_CODE: phf::Map<&'static str, Country> = phf_map! {
"AF" => Country::Afghanistan,
"AX" => Country::AlandIslands,
"AL" => Country::Albania,
"DZ" => Country::Algeria,
"AS" => Country::AmericanSamoa,
"AD" => Country::Andorra,
"AO" => Country::Angola,
"AI" => Country::Anguilla,
"AQ" => Country::Antarctica,
"AG" => Country::AntiguaAndBarbuda,
"AR" => Country::Argentina,
"AM" => Country::Armenia,
"AW" => Country::Aruba,
"AU" => Country::Australia,
"AT" => Country::Austria,
"AZ" => Country::Azerbaijan,
"BS" => Country::Bahamas,
"BH" => Country::Bahrain,
"BD" => Country::Bangladesh,
"BB" => Country::Barbados,
"BY" => Country::Belarus,
"BE" => Country::Belgium,
"BZ" => Country::Belize,
"BJ" => Country::Benin,
"BM" => Country::Bermuda,
"BT" => Country::Bhutan,
"BO" => Country::Bolivia,
"BQ" => Country::BonaireSintEustatiusAndSaba,
"BA" => Country::BosniaAndHerzegovina,
"BW" => Country::Botswana,
"BV" => Country::BouvetIsland,
"BR" => Country::Brazil,
"IO" => Country::BritishIndianOceanTerritory,
"VG" => Country::BritishVirginIslands,
"BN" => Country::Brunei,
"BG" => Country::Bulgaria,
"BF" => Country::BurkinaFaso,
"BI" => Country::Burundi,
"CV" => Country::CaboVerde,
"KH" => Country::Cambodia,
"CM" => Country::Cameroon,
"CA" => Country::Canada,
"KY" => Country::CaymanIslands,
"CF" => Country::CentralAfricanRepublic,
"TD" => Country::Chad,
"CL" => Country::Chile,
"CN" => Country::China,
"CX" => Country::ChristmasIsland,
"CC" => Country::CocosKeelingIslands,
"CO" => Country::Colombia,
"KM" => Country::Comoros,
"CG" => Country::CongoBraXXaville,
"CD" => Country::CongoKinshasa,
"CK" => Country::CookIslands,
"CR" => Country::CostaRica,
"CI" => Country::CotedIvoire,
"HR" => Country::Croatia,
"CU" => Country::Cuba,
"CW" => Country::Curacao,
"CY" => Country::Cyprus,
"CZ" => Country::Czechia,
"DK" => Country::Denmark,
"DJ" => Country::Djibouti,
"DM" => Country::Dominica,
"DO" => Country::DominicanRepublic,
"EC" => Country::Ecuador,
"EG" => Country::Egypt,
"SV" => Country::ElSalvador,
"GQ" => Country::EquatorialGuinea,
"ER" => Country::Eritrea,
"EE" => Country::Estonia,
"SZ" => Country::Eswatini,
"ET" => Country::Ethiopia,
"FK" => Country::FalklandIslands,
"FO" => Country::FaroeIslands,
"FJ" => Country::Fiji,
"FI" => Country::Finland,
"FR" => Country::France,
"GF" => Country::FrenchGuiana,
"PF" => Country::FrenchPolynesia,
"TF" => Country::FrenchSouthernTerritories,
"GA" => Country::Gabon,
"GM" => Country::Gambia,
"GE" => Country::Georgia,
"DE" => Country::Germany,
"GH" => Country::Ghana,
"GI" => Country::Gibraltar,
"GR" => Country::Greece,
"GL" => Country::Greenland,
"GD" => Country::Grenada,
"GP" => Country::Guadeloupe,
"GU" => Country::Guam,
"GT" => Country::Guatemala,
"GG" => Country::Guernsey,
"GN" => Country::Guinea,
"GW" => Country::GuineaBissau,
"GY" => Country::Guyana,
"HT" => Country::Haiti,
"HM" => Country::HeardAndMcDonaldIslands,
"VA" => Country::HolySee,
"HN" => Country::Honduras,
"HK" => Country::HongKong,
"HU" => Country::Hungary,
"IS" => Country::Iceland,
"IN" => Country::India,
"ID" => Country::Indonesia,
"IR" => Country::Iran,
"IQ" => Country::Iraq,
"IE" => Country::Ireland,
"IM" => Country::IsleOfMan,
"IL" => Country::Israel,
"IT" => Country::Italy,
"JM" => Country::Jamaica,
"JP" => Country::Japan,
"JE" => Country::Jersey,
"JO" => Country::Jordan,
"KZ" => Country::Kazakhstan,
"KE" => Country::Kenya,
"KI" => Country::Kiribati,
"KW" => Country::Kuwait,
"KG" => Country::Kyrgyzstan,
"LA" => Country::Laos,
"LV" => Country::Latvia,
"LB" => Country::Lebanon,
"LS" => Country::Lesotho,
"LR" => Country::Liberia,
"LY" => Country::Libya,
"LI" => Country::Liechtenstein,
"LT" => Country::Lithuania,
"LU" => Country::Luxembourg,
"MO" => Country::Macao,
"MG" => Country::Madagascar,
"MW" => Country::Malawi,
"MY" => Country::Malaysia,
"MV" => Country::Maldives,
"ML" => Country::Mali,
"MT" => Country::Malta,
"MH" => Country::MarshallIslands,
"MQ" => Country::Martinique,
"MR" => Country::Mauritania,
"MU" => Country::Mauritius,
"YT" => Country::Mayotte,
"MX" => Country::Mexico,
"FM" => Country::Micronesia,
"MD" => Country::Moldova,
"MC" => Country::Monaco,
"MN" => Country::Mongolia,
"ME" => Country::Montenegro,
"MS" => Country::Montserrat,
"MA" => Country::Morocco,
"MZ" => Country::Mozambique,
"MM" => Country::Myanmar,
"NA" => Country::Namibia,
"NR" => Country::Nauru,
"NP" => Country::Nepal,
"NL" => Country::Netherlands,
"NC" => Country::NewCaledonia,
"NZ" => Country::NewZealand,
"NI" => Country::Nicaragua,
"NE" => Country::Niger,
"NG" => Country::Nigeria,
"NU" => Country::Niue,
"NF" => Country::NorfolkIsland,
"MP" => Country::NorthernMarianaIslands,
"KP" => Country::NorthKorea,
"MK" => Country::NorthMacedonia,
"NO" => Country::Norway,
"OM" => Country::Oman,
"PK" => Country::Pakistan,
"PW" => Country::Palau,
"PS" => Country::Palestine,
"PA" => Country::Panama,
"PG" => Country::PapuaNewGuinea,
"PY" => Country::Paraguay,
"PE" => Country::Peru,
"PH" => Country::Philippines,
"PN" => Country::Pitcairn,
"PL" => Country::Poland,
"PT" => Country::Portugal,
"PR" => Country::PuertoRico,
"QA" => Country::Qatar,
"RE" => Country::Reunion,
"RO" => Country::Romania,
"RU" => Country::Russia,
"RW" => Country::Rwanda,
"WS" => Country::Samoa,
"SM" => Country::SanMarino,
"ST" => Country::SaoTomeAndPrincipe,
"SA" => Country::SaudiArabia,
"SN" => Country::Senegal,
"RS" => Country::Serbia,
"SC" => Country::Seychelles,
"SL" => Country::SierraLeone,
"SG" => Country::Singapore,
"SX" => Country::SintMaarten,
"SK" => Country::Slovakia,
"SI" => Country::Slovenia,
"SB" => Country::SolomonIslands,
"SO" => Country::Somalia,
"ZA" => Country::SouthAfrica,
"GS" => Country::SouthGeorgiaAndSouthSandwichIslands,
"KR" => Country::SouthKorea,
"SS" => Country::SouthSudan,
"ES" => Country::Spain,
"LK" => Country::SriLanka,
"BL" => Country::StBarthelemy,
"SH" => Country::StHelena,
"KN" => Country::StKittsAndNevis,
"LC" => Country::StLucia,
"MF" => Country::StMartin,
"PM" => Country::StPierreAndMiquelon,
"VC" => Country::StVincentAndGrenadines,
"SD" => Country::Sudan,
"SR" => Country::Suriname,
"SJ" => Country::SvalbardAndJanMayen,
"SE" => Country::Sweden,
"CH" => Country::Switzerland,
"SY" => Country::Syria,
"TW" => Country::Taiwan,
"TJ" => Country::Tajikistan,
"TZ" => Country::Tanzania,
"TH" => Country::Thailand,
"TL" => Country::TimorLeste,
"TG" => Country::Togo,
"TK" => Country::Tokelau,
"TO" => Country::Tonga,
"TT" => Country::TrinidadAndTobago,
"TN" => Country::Tunisia,
"TR" => Country::Turkey,
"TM" => Country::Turkmenistan,
"TC" => Country::TurksAndCaicosIslands,
"TV" => Country::Tuvalu,
"UG" => Country::Uganda,
"UA" => Country::Ukraine,
"AE" => Country::UnitedArabEmirates,
"GB" => Country::UnitedKingdom,
"US" => Country::UnitedStates,
"UM" => Country::UnitedStatesMinorOutlyingIslands,
"UY" => Country::Uruguay,
"VI" => Country::USVirginIslands,
"UZ" => Country::Uzbekistan,
"VU" => Country::Vanuatu,
"VE" => Country::Venezuela,
"VN" => Country::Vietnam,
"WF" => Country::WallisAndFutuna,
"EH" => Country::WesternSahara,
"YE" => Country::Yemen,
"ZM" => Country::Zambia,
"ZW" => Country::Zimbabwe,
"XX" => Country::Other,
};
impl std::convert::TryFrom<&str> for Country {
type Error = GoogleMapsError;
fn try_from(country_code: &str) -> Result<Self, Self::Error> {
Ok(COUNTRIES_BY_CODE
.get(country_code)
.copied()
.unwrap_or(Self::Other))
} }
impl std::str::FromStr for Country {
type Err = GoogleMapsError;
fn from_str(country_code: &str) -> Result<Self, Self::Err> {
Ok(COUNTRIES_BY_CODE
.get(country_code)
.copied()
.unwrap_or(Self::Other))
} }
impl Country {
#[must_use]
pub const fn display(&self) -> &str {
match self {
Self::Afghanistan => "Afghanistan",
Self::AlandIslands => "Ã…land Islands",
Self::Albania => "Albania",
Self::Algeria => "Algeria",
Self::AmericanSamoa => "American Samoa",
Self::Andorra => "Andorra",
Self::Angola => "Angola",
Self::Anguilla => "Anguilla",
Self::Antarctica => "Antarctica",
Self::AntiguaAndBarbuda => "Antigua and Barbuda",
Self::Argentina => "Argentina",
Self::Armenia => "Armenia",
Self::Aruba => "Aruba",
Self::Australia => "Australia",
Self::Austria => "Austria",
Self::Azerbaijan => "Azerbaijan",
Self::Bahamas => "Bahamas",
Self::Bahrain => "Bahrain",
Self::Bangladesh => "Bangladesh",
Self::Barbados => "Barbados",
Self::Belarus => "Belarus",
Self::Belgium => "Belgium",
Self::Belize => "Belize",
Self::Benin => "Benin",
Self::Bermuda => "Bermuda",
Self::Bhutan => "Bhutan",
Self::Bolivia => "Bolivia",
Self::BonaireSintEustatiusAndSaba => "Bonaire, Sint Eustatius and Saba",
Self::BosniaAndHerzegovina => "Bosnia and Herzegovina",
Self::Botswana => "Botswana",
Self::BouvetIsland => "Bouvet Island",
Self::Brazil => "Brazil",
Self::BritishIndianOceanTerritory => "British Indian Ocean Territory",
Self::BritishVirginIslands => "British Virgin Islands",
Self::Brunei => "Brunei",
Self::Bulgaria => "Bulgaria",
Self::BurkinaFaso => "Burkina Faso",
Self::Burundi => "Burundi",
Self::CaboVerde => "Cabo Verde",
Self::Cambodia => "Cambodia",
Self::Cameroon => "Cameroon",
Self::Canada => "Canada",
Self::CaymanIslands => "Cayman Islands",
Self::CentralAfricanRepublic => "Central African Republic",
Self::Chad => "Chad",
Self::Chile => "Chile",
Self::China => "China",
Self::ChristmasIsland => "Christmas Island",
Self::CocosKeelingIslands => "Cocos (Keeling) Islands",
Self::Colombia => "Colombia",
Self::Comoros => "Comoros",
Self::CongoBraXXaville => "Congo",
Self::CongoKinshasa => "Democratic Republic of the Congo",
Self::CookIslands => "Cook Islands",
Self::CostaRica => "Costa Rica",
Self::CotedIvoire => "Côte d'Ivoire",
Self::Croatia => "Croatia",
Self::Cuba => "Cuba",
Self::Curacao => "Curaçao",
Self::Cyprus => "Cyprus",
Self::Czechia => "Czechia",
Self::Denmark => "Denmark",
Self::Djibouti => "Djibouti",
Self::Dominica => "Dominica",
Self::DominicanRepublic => "Dominican Republic",
Self::Ecuador => "Ecuador",
Self::Egypt => "Egypt",
Self::ElSalvador => "El Salvador",
Self::EquatorialGuinea => "Equatorial Guinea",
Self::Eritrea => "Eritrea",
Self::Estonia => "Estonia",
Self::Eswatini => "Eswatini",
Self::Ethiopia => "Ethiopia",
Self::FalklandIslands => "Falkland Islands",
Self::FaroeIslands => "Faroe Islands",
Self::Fiji => "Fiji",
Self::Finland => "Finland",
Self::France => "France",
Self::FrenchGuiana => "French Guiana",
Self::FrenchPolynesia => "French Polynesia",
Self::FrenchSouthernTerritories => "French Southern Territories",
Self::Gabon => "Gabon",
Self::Gambia => "Gambia",
Self::Georgia => "Georgia",
Self::Germany => "Germany",
Self::Ghana => "Ghana",
Self::Gibraltar => "Gibraltar",
Self::Greece => "Greece",
Self::Greenland => "Greenland",
Self::Grenada => "Grenada",
Self::Guadeloupe => "Guadeloupe",
Self::Guam => "Guam",
Self::Guatemala => "Guatemala",
Self::Guernsey => "Guernsey",
Self::Guinea => "Guinea",
Self::GuineaBissau => "Guinea-Bissau",
Self::Guyana => "Guyana",
Self::Haiti => "Haiti",
Self::HeardAndMcDonaldIslands => "Heard Island and McDonald Islands",
Self::HolySee => "Holy See",
Self::Honduras => "Honduras",
Self::HongKong => "Hong Kong",
Self::Hungary => "Hungary",
Self::Iceland => "Iceland",
Self::India => "India",
Self::Indonesia => "Indonesia",
Self::Iran => "Iran",
Self::Iraq => "Iraq",
Self::Ireland => "Ireland",
Self::IsleOfMan => "Isle of Man",
Self::Israel => "Israel",
Self::Italy => "Italy",
Self::Jamaica => "Jamaica",
Self::Japan => "Japan",
Self::Jersey => "Jersey",
Self::Jordan => "Jordan",
Self::Kazakhstan => "Kazakhstan",
Self::Kenya => "Kenya",
Self::Kiribati => "Kiribati",
Self::Kuwait => "Kuwait",
Self::Kyrgyzstan => "Kyrgyzstan",
Self::Laos => "Laos",
Self::Latvia => "Latvia",
Self::Lebanon => "Lebanon",
Self::Lesotho => "Lesotho",
Self::Liberia => "Liberia",
Self::Libya => "Libya",
Self::Liechtenstein => "Liechtenstein",
Self::Lithuania => "Lithuania",
Self::Luxembourg => "Luxembourg",
Self::Macao => "Macao",
Self::Madagascar => "Madagascar",
Self::Malawi => "Malawi",
Self::Malaysia => "Malaysia",
Self::Maldives => "Maldives",
Self::Mali => "Mali",
Self::Malta => "Malta",
Self::MarshallIslands => "Marshall Islands",
Self::Martinique => "Martinique",
Self::Mauritania => "Mauritania",
Self::Mauritius => "Mauritius",
Self::Mayotte => "Mayotte",
Self::Mexico => "Mexico",
Self::Micronesia => "Micronesia",
Self::Moldova => "Moldova",
Self::Monaco => "Monaco",
Self::Mongolia => "Mongolia",
Self::Montenegro => "Montenegro",
Self::Montserrat => "Montserrat",
Self::Morocco => "Morocco",
Self::Mozambique => "Mozambique",
Self::Myanmar => "Myanmar",
Self::Namibia => "Namibia",
Self::Nauru => "Nauru",
Self::Nepal => "Nepal",
Self::Netherlands => "Netherlands",
Self::NewCaledonia => "New Caledonia",
Self::NewZealand => "New Zealand",
Self::Nicaragua => "Nicaragua",
Self::Niger => "Niger",
Self::Nigeria => "Nigeria",
Self::Niue => "Niue",
Self::NorfolkIsland => "Norfolk Island",
Self::NorthernMarianaIslands => "Northern Mariana Islands",
Self::NorthKorea => "North Korea",
Self::NorthMacedonia => "North Macedonia",
Self::Norway => "Norway",
Self::Oman => "Oman",
Self::Pakistan => "Pakistan",
Self::Palau => "Palau",
Self::Palestine => "Palestine",
Self::Panama => "Panama",
Self::PapuaNewGuinea => "Papua New Guinea",
Self::Paraguay => "Paraguay",
Self::Peru => "Peru",
Self::Philippines => "Philippines",
Self::Pitcairn => "Pitcairn",
Self::Poland => "Poland",
Self::Portugal => "Portugal",
Self::PuertoRico => "Puerto Rico",
Self::Qatar => "Qatar",
Self::Reunion => "Réunion",
Self::Romania => "Romania",
Self::Russia => "Russian Federation",
Self::Rwanda => "Rwanda",
Self::Samoa => "Samoa",
Self::SanMarino => "San Marino",
Self::SaoTomeAndPrincipe => "Sao Tome and Principe",
Self::SaudiArabia => "Saudi Arabia",
Self::Senegal => "Senegal",
Self::Serbia => "Serbia",
Self::Seychelles => "Seychelles",
Self::SierraLeone => "Sierra Leone",
Self::Singapore => "Singapore",
Self::SintMaarten => "Sint Maarten",
Self::Slovakia => "Slovakia",
Self::Slovenia => "Slovenia",
Self::SolomonIslands => "Solomon Islands",
Self::Somalia => "Somalia",
Self::SouthAfrica => "SouthA frica",
Self::SouthGeorgiaAndSouthSandwichIslands => {
"South Georgia and the South Sandwich Islands"
}
Self::SouthKorea => "South Korea",
Self::SouthSudan => "South Sudan",
Self::Spain => "Spain",
Self::SriLanka => "Sri Lanka",
Self::StBarthelemy => "Saint Barthélemy",
Self::StHelena => "Saint Helena, Ascension and Tristan da Cunha",
Self::StKittsAndNevis => "Saint Kitts and Nevis",
Self::StLucia => "Saint Lucia",
Self::StMartin => "Saint Martin",
Self::StPierreAndMiquelon => "Saint Pierre and Miquelon",
Self::StVincentAndGrenadines => "Saint Vincent and the Grenadines",
Self::Sudan => "Sudan",
Self::Suriname => "Suriname",
Self::SvalbardAndJanMayen => "Svalbard and Jan Mayen",
Self::Sweden => "Sweden",
Self::Switzerland => "Switzerland",
Self::Syria => "Syria",
Self::Taiwan => "Taiwan, Province of China",
Self::Tajikistan => "Tajikistan",
Self::Tanzania => "Tanzania",
Self::Thailand => "Thailand",
Self::TimorLeste => "Timor-Leste",
Self::Togo => "Togo",
Self::Tokelau => "Tokelau",
Self::Tonga => "Tonga",
Self::TrinidadAndTobago => "Trinidad and Tobago",
Self::Tunisia => "Tunisia",
Self::Turkey => "Turkey",
Self::Turkmenistan => "Turkmenistan",
Self::TurksAndCaicosIslands => "Turks and Caicos Islands",
Self::Tuvalu => "Tuvalu",
Self::Uganda => "Uganda",
Self::Ukraine => "Ukraine",
Self::UnitedArabEmirates => "United Arab Emirates",
Self::UnitedKingdom => "United Kingdom",
Self::UnitedStates => "United States",
Self::UnitedStatesMinorOutlyingIslands => "United States Minor Outlying Islands",
Self::Uruguay => "Uruguay",
Self::USVirginIslands => "US Virgin ISlands",
Self::Uzbekistan => "Uzbekistan",
Self::Vanuatu => "Vanuatu",
Self::Venezuela => "Venezuela",
Self::Vietnam => "Viet Nam",
Self::WallisAndFutuna => "Wallis and Futuna",
Self::WesternSahara => "Western Sahara",
Self::Yemen => "Yemen",
Self::Zambia => "Zambia",
Self::Zimbabwe => "Zimbabwe",
Self::Other => "Other",
} } }