#iso #country #codes #query #data #countries #currencies

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 687/week @ 2023-12-22 257/week @ 2023-12-29 600/week @ 2024-01-05 617/week @ 2024-01-12 968/week @ 2024-01-19 782/week @ 2024-01-26 811/week @ 2024-02-02 612/week @ 2024-02-09 644/week @ 2024-02-16 547/week @ 2024-02-23 870/week @ 2024-03-01 670/week @ 2024-03-08 595/week @ 2024-03-15 543/week @ 2024-03-22 854/week @ 2024-03-29 1098/week @ 2024-04-05

3,180 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
~52K SLoC