ISO 4217 currency, fund, precious-metal, and historic-code data for Rust and WebAssembly.
The crate provides alpha-code, numeric-code, and ISO 3166-1 alpha-3 country lookups backed by compile-time perfect hash maps.
[dependencies]
rust_iso4217 = "0.1.4"The minimum supported Rust version is 1.85.
use rust_iso4217::{from_code, from_country, from_numeric, from_numeric_str};
assert_eq!(from_code("eur"), Some(rust_iso4217::EUR));
assert_eq!(from_numeric(360), Some(rust_iso4217::IDR));
assert_eq!(from_numeric_str("643"), Some(rust_iso4217::RUB));
assert_eq!(from_country("chn"), vec![rust_iso4217::CNY]);
// Unknown country codes return an empty vector.
assert!(from_country("unknown").is_empty());The complete collections are available through ALL_CODES, ALL_MAP,
NUMERIC_MAP, COUNTRY_MAP, ALL_ACTIVE_CODE, ALL_FUNDS_CODE, and
ALL_HISTORIC_CODE.
Each entry is represented by:
pub struct CurrencyCode {
pub name: &'static str,
pub code: &'static str,
pub numeric: i32,
pub unit: i32,
pub code_type: &'static str, // "currency", "funds", or "historic"
pub countries: &'static [&'static str], // ISO 3166-1 alpha-3 codes
}For entries where ISO 4217 specifies no numeric code or minor unit, the value
is -1.
Build the browser-targeted npm package with:
scripts/build-wasm.shThe generated JavaScript API includes from_code, from_numeric,
from_numeric_str, from_country, all_active_code, all_funds_code, and
all_historic_code.
The generated data was verified on 2026-09-28 against:
- SIX Group, the official ISO 4217 Maintenance Agency, for List One, List Two, and List Three.
- Datahub Country Codes, for ISO 3166-1 country-to-currency relationships.
The current SIX List One and List Three files are unchanged from the
2026-01-01 data refresh. List Two includes the Arab Accounting Dinar (XAD),
which is exposed as a funds code.
To regenerate the checked-in Rust source, install the Python dependencies and
run the generator from the scripts directory:
python3 -m pip install -r scripts/requirements.txt
cd scripts
python3 generate.py > ../src/lib.rsFormat and test the generated source before committing it.
Bug reports, data corrections, and pull requests are welcome in the GitHub repository.
If this project saves you time, you can support its maintenance on Ko-fi.
Licensed under the Apache License 2.0.