5 releases
0.1.4 | Apr 9, 2024 |
---|---|
0.1.3 | Oct 8, 2021 |
0.1.2 | Sep 30, 2021 |
0.1.1 | Jun 17, 2021 |
0.1.0 | Jun 17, 2021 |
#100 in Value formatting
2,226 downloads per month
79KB
618 lines
iso-rs
ISO-rs provides methods to query ISO country data. This includes
- names
- capitals
- regions
- alpha 2 codes
- alpha 3 codes
- timezones
- currencies
- languages
- call codes
Overview
use iso_rs::prelude::*;
let country = Country::from_name("India").unwrap();
assert_eq!(country.capital.unwrap(), "New Delhi");
LICENSE
MIT
lib.rs
:
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, captials, 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.
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");
Dependencies
~1.4–3.5MB
~51K SLoC