Expand description
This package contains an implementation of the ISO 3166, parts 1 and 2, standard.
The purpose of ISO 3166 is to define internationally recognized codes of letters and/or numbers that we can use when we refer to countries and their subdivisions. However, it does not define the names of countries – this information comes from United Nations sources (Terminology Bulletin Country Names and the Country and Region Codes for Statistical Use maintained by the United Nations Statistics Divisions).
The country codes can be represented either as a two-letter code (alpha-2) which is recommended as the general-purpose code, a three-letter code (alpha-3) which is more closely related to the country name and a three-digit numeric code (numeric-3) which can be useful if you need to avoid using Latin script.
§Example
This example shows the use of the part-1 Country Code.
use codes_iso_3166::part_1::CountryCode;
use std::str::FromStr;
let country = CountryCode::from_str("AG").unwrap();
assert_eq!(country.alpha_2_code(), "AG");
assert_eq!(country.short_name(), "Antigua and Barbuda");§Features
By default only the serde feature is enabled, and part_1 two-letter
language codes.
serde- Enables serialization of the different Language Code types.alpha_3_code- Adds theCountryCode::alpha_3_codemethod.numeric_code- Adds theCountryCode::numeric_codemethod.independent- Adds theCountryCode::independentmethod.status- Adds theCountryCode::statusmethod.full_name- Adds theCountryCode::full_namemethod.local_names- Adds theCountryCode::local_short_nameandCountryCode::local_full_namemethods.languages- Adds theCountryCode::administrative_languageandCountryCode::languagesmethods (requires packagecodes-iso-639).formerly- Adds theCountryCode::former_short_nameandCountryCode::former_alpha_3_codemethods.part_2- Adds the corresponding module andSubdivisionCode.categories- Adds theSubdivisionCode::category_codemethod andSubdivisionCategoryCodetype.territories- Adds theTerritoryCodetype.languages- Adds theSubdivisionCode::name_languagemethod.
Note that the method CountryCode::local_full_name requires both
local_names and full_name features.
Modules§
- part_1
- Codes for the representation of names of countries and their subdivisions – Part 1: Country codes, defines codes for the names of countries, dependent territories, and special areas of geographical interest.
- part_2
- Codes for the representation of names of countries and their subdivisions – Part 2: Country subdivision code, defines codes for the names of the principal subdivisions (e.g., provinces, states, departments, regions) of all countries coded in ISO 3166-1.
Enums§
- Country
Code Error - Common
Errortype, mainly used forFromStrfailures.