https://github.com/sifton/iso3166-1.rs
Rust crate for ISO 3166-1 data.
https://github.com/sifton/iso3166-1.rs
Last synced: 3 months ago
JSON representation
Rust crate for ISO 3166-1 data.
- Host: GitHub
- URL: https://github.com/sifton/iso3166-1.rs
- Owner: sifton
- License: isc
- Created: 2018-05-31T16:27:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T18:06:50.000Z (over 7 years ago)
- Last Synced: 2025-01-25T21:27:59.648Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![ci-badge][]][ci] [![license-badge][]][license]
# iso3166-1.rs
Rust crate for ISO 3166-1 data.
[Documentation](http://docs.rs/iso3166_1)
### 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.
>
> -- [Wikipedia](https://en.wikipedia.org/wiki/ISO_3166-1)### Installation
Add the following dependency to your `Cargo.toml`:
```toml
iso3166_1 = "^1.0"
```And include it in your project:
```rust
extern crate iso3166_1;
```### Examples
Retrieve all country codes:
```rust
let countries = iso3166_1::all();
```Retrieve a country code by its alpha2 code:
```rust
let country = iso3166_1::alpha2("AF").unwrap();
```Retrieve a country code by its alpha3 code:
```rust
let country = iso3166_1::alpha3("ATA").unwrap();
```Retrieve a country code by its name:
```rust
let country = iso3166_1::name("Angola").unwrap();
```Retrieve a country code by its numeric number:
```rust
let country = iso3166_1::num("016").unwrap();
```Retrieve country codes by a range of their numeric numbers:
```rust
// Getting all values between `100` and `300`:
iso3166_1::num_range(Some("100"), Some("300"));// Getting all values from `400` and beyond:
iso3166_1::num_range(Some("400"), None);// Getting all values up to `500`:
iso3166_1::num_range(None, Some("500"));// Getting no values, if that's your thing:
iso3166_1::num_range(None, None);
```### License
License info in [LICENSE.md]. Long story short, ISC.
[ci]: https://github.com/zeyla/iso3166-1.rs/pipelines
[ci-badge]: https://github.com/zeyla/iso3166-1.rs/badges/master/build.svg
[license]: https://opensource.org/licenses/ISC
[license-badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square
[LICENSE.md]: https://github.com/zeyla/iso3166-1.rs/blob/master/LICENSE.md