Enum keshvar::Alpha2

source ·
pub enum Alpha2 {
Show 249 variants AD, AE, AF, AG, AI, AL, AM, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MH, MK, ML, MM, MN, MO, MP, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, ZA, ZM, ZW,
}
Expand description

An enum containing Alpha2 codes for all countries.

All countries features are enabled by default. You can disable default features and enabled features for all countries that you need.

§Examples

use keshvar::{Alpha2, Alpha3, Country, SearchError, SearchedItems};

assert_eq!(Ok(Alpha2::US), Alpha2::try_from("us")); // not case-sensitive
assert_eq!("US", Alpha2::US.to_string().as_str());

// If enabled all countries features:
assert_eq!(
    Err(SearchError::NotFound {
        searched_items: SearchedItems::AllCountries
    }),
    Alpha2::try_from("xx")
);
assert_eq!(
    Err("Could not be found in all countries".to_string()),
    Alpha2::try_from("xx").map_err(|error| error.to_string())
);

// If enabled some countries features:
// For example we enabled supporting just 10 countries and the US
// is not one of them:
// assert_eq!(
//     Err(SearchError::NotFound {
//         searched_items: SearchedItems::SupportedCountries(10)
//     }),
//     Alpha2::try_from("us")
// );
// assert_eq!(
//     Err("Could not be found in 10 supported countries".to_string()),
//     Alpha2::try_from("us").map_err(|error| error.to_string())
// );

// Convert to `Alpha3` code:
assert_eq!(Alpha3::USA, Alpha2::US.to_alpha3());
// Convert to `Country`:
let country: Country = Alpha2::US.to_country();
// Get subdivisions of country:
let subdivisions = Alpha2::US.to_subdivisions();

We usually need to convert it to Country and use that object instead.

§Panics

Most methods will panic if you do not enable any country feature!

Variants§

§

AD

The Principality of Andorra (Europe)

§

AE

The United Arab Emirates (Asia)

§

AF

The Islamic Republic of Afghanistan (Asia)

§

AG

Antigua and Barbuda (Americas)

§

AI

Anguilla (Americas)

§

AL

The Republic of Albania (Europe)

§

AM

The Republic of Armenia (Asia)

§

AO

The Republic of Angola (Africa)

§

AQ

Antarctica

§

AR

The Argentine Republic (Americas)

§

AS

The Territory of American Samoa (Oceania)

§

AT

The Republic of Austria (Europe)

§

AU

The Commonwealth of Australia (Oceania)

§

AW

Aruba (Americas)

§

AX

Åland (Europe)

§

AZ

The Republic of Azerbaijan (Asia)

§

BA

Bosnia and Herzegovina (Europe)

§

BB

Barbados (Americas)

§

BD

The People’s Republic of Bangladesh (Asia)

§

BE

The Kingdom of Belgium (Europe)

§

BF

Burkina Faso (Africa)

§

BG

The Republic of Bulgaria (Europe)

§

BH

The Kingdom of Bahrain (Asia)

§

BI

The Republic of Burundi (Africa)

§

BJ

The Republic of Benin (Africa)

§

BL

The Collectivity of Saint-Barthélemy (Americas)

§

BM

Bermuda (Americas)

§

BN

The Nation of Brunei, the Abode of Peace (Asia)

§

BO

The Plurinational State of Bolivia (Americas)

§

BQ

Bonaire, Sint Eustatius and Saba (Americas)

§

BR

The Federative Republic of Brazil (Americas)

§

BS

The Commonwealth of The Bahamas (Americas)

§

BT

The Kingdom of Bhutan (Asia)

§

BV

Bouvet Island

§

BW

The Republic of Botswana (Africa)

§

BY

The Republic of Belarus (Europe)

§

BZ

Belize (Americas)

§

CA

Canada (Americas)

§

CC

The Territory of Cocos (Keeling) Islands (Oceania)

§

CD

The Democratic Republic of the Congo (Africa)

§

CF

The Central African Republic (Africa)

§

CG

The Republic of the Congo (Africa)

§

CH

The Swiss Confederation (Europe)

§

CI

The Republic of Côte d’Ivoire (Africa)

§

CK

The Cook Islands (Oceania)

§

CL

The Republic of Chile (Americas)

§

CM

The Republic of Cameroon (Africa)

§

CN

The People’s Republic of China (Asia)

§

CO

The Republic of Colombia (Americas)

§

CR

The Republic of Costa Rica (Americas)

§

CU

The Republic of Cuba (Americas)

§

CV

The Republic of Cabo Verde (Africa)

§

CW

The Country of Curaçao (Americas)

§

CX

The Territory of Christmas Island (Oceania)

§

CY

The Republic of Cyprus (Asia)

§

CZ

The Czech Republic (Europe)

§

DE

The Federal Republic of Germany (Europe)

§

DJ

The Republic of Djibouti (Africa)

§

DK

The Kingdom of Denmark (Europe)

§

DM

The Commonwealth of Dominica (Americas)

§

DO

The Dominican Republic (Americas)

§

DZ

The People’s Democratic Republic of Algeria (Africa)

§

EC

The Republic of Ecuador (Americas)

§

EE

The Republic of Estonia (Europe)

§

EG

The Arab Republic of Egypt (Africa)

§

EH

The Sahrawi Arab Democratic Republic (Africa)

§

ER

The State of Eritrea (Africa)

§

ES

The Kingdom of Spain (Europe)

§

ET

The Federal Democratic Republic of Ethiopia (Africa)

§

FI

The Republic of Finland (Europe)

§

FJ

The Republic of Fiji (Oceania)

§

FK

The Falkland Islands (Americas)

§

FM

The Federated States of Micronesia (Oceania)

§

FO

The Faroe Islands (Europe)

§

FR

The French Republic (Europe)

§

GA

The Gabonese Republic (Africa)

§

GB

The United Kingdom of Great Britain and Northern Ireland (Europe)

§

GD

Grenada (Americas)

§

GE

Georgia (Asia)

§

GF

Guyane (Americas)

§

GG

The Bailiwick of Guernsey (Europe)

§

GH

The Republic of Ghana (Africa)

§

GI

Gibraltar (Europe)

§

GL

Kalaallit Nunaat (Americas)

§

GM

The Republic of The Gambia (Africa)

§

GN

The Republic of Guinea (Africa)

§

GP

Guadeloupe (Americas)

§

GQ

The Republic of Equatorial Guinea (Africa)

§

GR

The Hellenic Republic (Europe)

§

GS

South Georgia and the South Sandwich Islands (Americas)

§

GT

The Republic of Guatemala (Americas)

§

GU

The Territory of Guam (Oceania)

§

GW

The Republic of Guinea-Bissau (Africa)

§

GY

The Co-operative Republic of Guyana (Americas)

§

HK

The Hong Kong Special Administrative Region of China (Asia)

§

HM

The Territory of Heard Island and McDonald Islands

§

HN

The Republic of Honduras (Americas)

§

HR

The Republic of Croatia (Europe)

§

HT

The Republic of Haiti (Americas)

§

HU

Hungary (Europe)

§

ID

The Republic of Indonesia (Asia)

§

IE

Ireland (Europe)

§

IL

The State of Israel (Asia)

§

IM

The Isle of Man (Europe)

§

IN

The Republic of India (Asia)

§

IO

The British Indian Ocean Territory (Africa)

§

IQ

The Republic of Iraq (Asia)

§

IR

The Islamic Republic of Iran (Asia)

§

IS

Iceland (Europe)

§

IT

The Italian Republic (Europe)

§

JE

The Bailiwick of Jersey (Europe)

§

JM

Jamaica (Americas)

§

JO

The Hashemite Kingdom of Jordan (Asia)

§

JP

Japan (Asia)

§

KE

The Republic of Kenya (Africa)

§

KG

The Kyrgyz Republic (Asia)

§

KH

The Kingdom of Cambodia (Asia)

§

KI

The Republic of Kiribati (Oceania)

§

KM

The Union of the Comoros (Africa)

§

KN

Saint Kitts and Nevis (Americas)

§

KP

The Democratic People’s Republic of Korea (Asia)

§

KR

The Republic of Korea (Asia)

§

KW

The State of Kuwait (Asia)

§

KY

The Cayman Islands (Americas)

§

KZ

The Republic of Kazakhstan (Asia)

§

LA

The Lao People’s Democratic Republic (Asia)

§

LB

The Lebanese Republic (Asia)

§

LC

Saint Lucia (Americas)

§

LI

The Principality of Liechtenstein (Europe)

§

LK

The Democratic Socialist Republic of Sri Lanka (Asia)

§

LR

The Republic of Liberia (Africa)

§

LS

The Kingdom of Lesotho (Africa)

§

LT

The Republic of Lithuania (Europe)

§

LU

The Grand Duchy of Luxembourg (Europe)

§

LV

The Republic of Latvia (Europe)

§

LY

The State of Libya (Africa)

§

MA

The Kingdom of Morocco (Africa)

§

MC

The Principality of Monaco (Europe)

§

MD

The Republic of Moldova (Europe)

§

ME

Montenegro (Europe)

§

MF

The Collectivity of Saint-Martin (Americas)

§

MG

The Republic of Madagascar (Africa)

§

MH

The Republic of the Marshall Islands (Oceania)

§

MK

The Republic of North Macedonia (Europe)

§

ML

The Republic of Mali (Africa)

§

MM

The Republic of the Union of Myanmar (Asia)

§

MN

Mongolia (Asia)

§

MO

The Macao Special Administrative Region of China (Asia)

§

MP

The Commonwealth of the Northern Mariana Islands (Oceania)

§

MQ

Martinique (Americas)

§

MR

The Islamic Republic of Mauritania (Africa)

§

MS

Montserrat (Americas)

§

MT

The Republic of Malta (Europe)

§

MU

The Republic of Mauritius (Africa)

§

MV

The Republic of Maldives (Asia)

§

MW

The Republic of Malawi (Africa)

§

MX

The United Mexican States (Americas)

§

MY

Malaysia (Asia)

§

MZ

The Republic of Mozambique (Africa)

§

NA

The Republic of Namibia (Africa)

§

NC

New Caledonia (Oceania)

§

NE

The Republic of the Niger (Africa)

§

NF

The Territory of Norfolk Island (Oceania)

§

NG

The Federal Republic of Nigeria (Africa)

§

NI

The Republic of Nicaragua (Americas)

§

NL

The Kingdom of the Netherlands (Europe)

§

NO

The Kingdom of Norway (Europe)

§

NP

The Federal Democratic Republic of Nepal (Asia)

§

NR

The Republic of Nauru (Oceania)

§

NU

Niue (Oceania)

§

NZ

New Zealand (Oceania)

§

OM

The Sultanate of Oman (Asia)

§

PA

The Republic of Panamá (Americas)

§

PE

The Republic of Perú (Americas)

§

PF

French Polynesia (Oceania)

§

PG

The Independent State of Papua New Guinea (Oceania)

§

PH

The Republic of the Philippines (Asia)

§

PK

The Islamic Republic of Pakistan (Asia)

§

PL

The Republic of Poland (Europe)

§

PM

The Overseas Collectivity of Saint-Pierre and Miquelon (Americas)

§

PN

The Pitcairn, Henderson, Ducie and Oeno Islands (Oceania)

§

PR

The Commonwealth of Puerto Rico (Americas)

§

PS

The State of Palestine (Asia)

§

PT

The Portuguese Republic (Europe)

§

PW

The Republic of Palau (Oceania)

§

PY

The Republic of Paraguay (Americas)

§

QA

The State of Qatar (Asia)

§

RE

Réunion (Africa)

§

RO

Romania (Europe)

§

RS

The Republic of Serbia (Europe)

§

RU

The Russian Federation (Europe)

§

RW

The Republic of Rwanda (Africa)

§

SA

The Kingdom of Saudi Arabia (Asia)

§

SB

The Solomon Islands (Oceania)

§

SC

The Republic of Seychelles (Africa)

§

SD

The Republic of the Sudan (Africa)

§

SE

The Kingdom of Sweden (Europe)

§

SG

The Republic of Singapore (Asia)

§

SH

Saint Helena, Ascension and Tristan da Cunha (Africa)

§

SI

The Republic of Slovenia (Europe)

§

SJ

Svalbard and Jan Mayen (Europe)

§

SK

The Slovak Republic (Europe)

§

SL

The Republic of Sierra Leone (Africa)

§

SM

The Republic of San Marino (Europe)

§

SN

The Republic of Senegal (Africa)

§

SO

The Federal Republic of Somalia (Africa)

§

SR

The Republic of Suriname (Americas)

§

SS

The Republic of South Sudan (Africa)

§

ST

The Democratic Republic of São Tomé and Príncipe (Africa)

§

SV

The Republic of El Salvador (Americas)

§

SX

Sint Maarten (Americas)

§

SY

The Syrian Arab Republic (Asia)

§

SZ

The Kingdom of Eswatini (Africa)

§

TC

The Turks and Caicos Islands (Americas)

§

TD

The Republic of Chad (Africa)

§

TF

The French Southern and Antarctic Lands (Africa)

§

TG

The Togolese Republic (Africa)

§

TH

The Kingdom of Thailand (Asia)

§

TJ

The Republic of Tajikistan (Asia)

§

TK

Tokelau (Oceania)

§

TL

The Democratic Republic of Timor-Leste (Asia)

§

TM

Turkmenistan (Asia)

§

TN

The Republic of Tunisia (Africa)

§

TO

The Kingdom of Tonga (Oceania)

§

TR

The Republic of Türkiye (Asia)

§

TT

The Republic of Trinidad and Tobago (Americas)

§

TV

Tuvalu (Oceania)

§

TW

Taiwan, Province of China (Asia)

§

TZ

The United Republic of Tanzania (Africa)

§

UA

Ukraine (Europe)

§

UG

The Republic of Uganda (Africa)

§

UM

United States Minor Outlying Islands (Americas)

§

US

The United States of America (Americas)

§

UY

The Oriental Republic of Uruguay (Americas)

§

UZ

The Republic of Uzbekistan (Asia)

§

VA

The Holy See (Europe)

§

VC

Saint Vincent and the Grenadines (Americas)

§

VE

The Bolivarian Republic of Venezuela (Americas)

§

VG

The Virgin Islands (Americas)

§

VI

The Virgin Islands of the United States (Americas)

§

VN

The Socialist Republic of Viet Nam (Asia)

§

VU

The Republic of Vanuatu (Oceania)

§

WF

The Territory of the Wallis and Futuna Islands (Oceania)

§

WS

The Independent State of Samoa (Oceania)

§

YE

The Republic of Yemen (Asia)

§

YT

The Department of Mayotte (Africa)

§

ZA

The Republic of South Africa (Africa)

§

ZM

The Republic of Zambia (Africa)

§

ZW

The Republic of Zimbabwe (Africa)

Implementations§

Trait Implementations§

source§

impl Clone for Alpha2

source§

fn clone(&self) -> Alpha2

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Alpha2

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Alpha2

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Alpha2> for Alpha3

source§

fn from(alpha2: Alpha2) -> Self

Converts to this type from the input type.
source§

impl From<Alpha2> for Country

source§

fn from(alpha2: Alpha2) -> Self

Converts to this type from the input type.
source§

impl From<Alpha3> for Alpha2

source§

fn from(alpha3: Alpha3) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Alpha2

source§

fn eq(&self, other: &Alpha2) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Alpha2

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToString for Alpha2

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl TryFrom<&str> for Alpha2

§

type Error = SearchError

The type returned in the event of a conversion error.
source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Alpha2

source§

impl StructuralPartialEq for Alpha2

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,