Expand description
iso-rs crate provides methods to extract ISO 3166-1 (codes for country and dependent area names)
ISO 639-1 (Alpha-2 code), ISO 639-2 (Alpha-3 code) (Codes for the representation of names of languages)
codes, timezones, capitals, regions, subregions, ISO 4217 currency codes, etc. for all countries.
iso-rs crate is powered by the REST Countries API
If you find this library useful and would like to show your gratitude, consider
donating to the restcountries project.
The crate allows you to query for country data by various fields. It pulls the data from the restcountries API and generates a compile-time static map using phf-codegen. The methods just query these maps. You can query countries by their name, capital (enable feature), etc.
§Features
from_capitals: Allows you to query country data by country capitals.from_alpha_2: Allows you to query country data by alpha_2 codes.from_alpha_3: Allows you to query country data by alpha_3 codes.from_regions: Allows you to query country data by their regions.from_subregions: Allows you to query country data by their subregions.
By default all these features are enabled. It is recommended to turn off the features you will not be using as the country data is high in number and you’ll be saving some static allocation.
§Example
use iso_rs::prelude::*;
let country = Country::from_name("India").unwrap();
assert_eq!(country.capital.unwrap(), "New Delhi");Modules§
- prelude
- Prelude brings the
Country,CurrencyandLanguagestructs in scope.
Structs§
- Country
- Represents a Country.
- Currency
- Represents a Currency with ISO 4217 code.
- Language
- Represents a Language with both ISO 639-1 and ISO 639-2 codes.
- Timezone
- Represents a timezone with offset (UTC) and the IANA identifier
Statics§
- ALPHA_2
- Map of all alpha_2 codes (key) with the corresponding countries as values.
- ALPHA_3
- Map of all alpha_3 codes (key) with the corresponding countries as values.
- CAPITALS
- Map of all capitals with their countries as the value as an array of
Country. - NAMES
- Map of all the countries with name as the key and value as
Country. - REGIONS
- Map of all regions with countries that reside in them.
- SUBREGIONS
- Map of all subregions with countries that reside in them.