#country-code #iso #timezone #codes #language #query #currency

iso-rs

A crate to query ISO data, which includes countries, currencies, etc

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

#95 in Value formatting

Download history 531/week @ 2024-07-27 621/week @ 2024-08-03 539/week @ 2024-08-10 407/week @ 2024-08-17 676/week @ 2024-08-24 629/week @ 2024-08-31 542/week @ 2024-09-07 348/week @ 2024-09-14 542/week @ 2024-09-21 757/week @ 2024-09-28 647/week @ 2024-10-05 693/week @ 2024-10-12 940/week @ 2024-10-19 868/week @ 2024-10-26 1034/week @ 2024-11-02 679/week @ 2024-11-09

3,690 downloads per month

MIT license

79KB
618 lines

iso-rs

MIT license

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–4MB
~51K SLoC