rust_iso/iso3166

A rust crate providing ISO 3166 1, ISO 3166 2, ISO 3166 3 support.

What is ISO 3166-1

ISO 3166-1 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO), and defines codes for the names of countries, dependent territories, and special areas of geographical interest. The official name of the standard is Codes for the representation of names of countries and their subdivisions – Part 1: Country codes. It defines three sets of country codes: * ISO 3166-1 alpha-2 – two-letter country codes which are the most widely used of the three, and used most prominently for the Internet's country code top-level domains (with a few exceptions). * ISO 3166-1 alpha-3 – three-letter country codes which allow a better visual association between the codes and the country names than the alpha-2 codes. * ISO 3166-1 numeric – three-digit country codes which are identical to those developed and maintained by the United Nations Statistics Division, with the advantage of script (writing system) independence, and hence useful for people or systems using non-Latin scripts.

-- Wikipedia

What is ISO 3166-2

ISO 3166-2 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO), and defines codes for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1. The official name of the standard is Codes for the representation of names of countries and their subdivisions – Part 2: Country subdivision code. It was first published in 1998.

-- Wikipedia

What is ISO 3166-3

ISO 3166-3 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO), and defines codes for country names which have been deleted from ISO 3166-1 since its first publication in 1974. The official name of the standard is Codes for the representation of names of countries and their subdivisions – Part 3: Code for formerly used names of countries.[1] It was first published in 1999.

-- Wikipedia

Installing

sh [dependencies] rust_iso3166 = "0.1.4"

Using

See using section of the documentation.

Quick guide:

``` rust let country = rustiso3166::fromalpha2("AU"); let country = rustiso3166::fromalpha3("AUS"); let country = rustiso3166::fromnumeric(036); let country = rustiso3166::fromnumeric_str("036");

println!("{:?}", rust_iso3166::ALL);

println!("{:?}", rustiso3166::ALLALPHA2);
println!("{:?}", rustiso3166::ALLALPHA3);
println!("{:?}", rustiso3166::ALLNAME);
println!("{:?}", rustiso3166::ALLNUMERIC);
println!("{:?}", rustiso3166::ALLNUMERIC_STR);

println!("{:?}", rustiso3166::NUMERICMAP);
println!("{:?}", rustiso3166::ALPHA3MAP);
println!("{:?}", rustiso3166::ALPHA2MAP);

// for ISO 3166-2 let country = rustiso3166::fromalpha2("GB").unwrap(); let subdivisions = country.subdivisions(); assert!(subdivisions.unwrap().len() > 0); let country = rustiso3166::iso31662::fromcode("GB-EDH"); asserteq!("Edinburgh, City of", country.unwrap().name);

// for ISO 3166-3 let sub = rustiso3166::iso31663::fromcode("PZPA"); asserteq!("Panama Canal Zone", sub.unwrap().name); ```

Data sample:

``` rust CountryCode { name: "Australia", alpha2: "AU", alpha3: "AUS", numeric: 36 }

iso31662::Subdivision { name: "Bādghīs", code: "AF-BDG", subdivisiontype: "Province", countryname: "Afghanistan", countrycode: "AF", region_code: "AF-BDG", }

iso31663::CountryCode3 { code: "BQAQ", name: "British Antarctic Territory", former: CountryCode { name: "British Antarctic Territory", alpha2: "BQ", alpha3: "ATB", numeric: 0 }, newcountries: [ CountryCode { name: "Antarctica", alpha2: "AQ", alpha3: "ATA", numeric: 010 },
], validity: [1974,1979], desc: "Merged into Antarctica", } ```

Contributing

Feel free to submit a pull request or create an issue. or request to rust-iso

License

rust-iso/rust_iso3166 is licensed under the Apache-2.0 license.

Source(s)