iso4217-static

Crates.ioiso4217-static
lib.rsiso4217-static
version0.2.2
created_at2026-01-11 20:29:38.386248+00
updated_at2026-01-15 04:15:06.077811+00
descriptionStatic ISO 4217 Data
homepage
repositoryhttps://github.com/jcape/iso4217
max_upload_size
id2036388
size63,544
James Cape (jcape)

documentation

https://docs.rs/iso4217-static

README

Static ISO 4217 Currency Data

Crates.ioDocs StatusMSRV 1.88.0

This crate provides a no-std and no-std::no-alloc capable enumeration of ISO 4217 Currency-code data, vis-a-vis the Currency Rust enum. It requires Rust 1.88.0 or later, and MSRV updates are not considered breaking changes.

Features

  • default: Enables the serde feature.
  • serde: Enables serialization/deserialization using serde.
  • alloc: Enables the use of allocated types (this should be enabled if serde is enabled).
  • zerocopy: Enables the derivation of zerocopy traits (specifically, TryFromBytes and IntoBytes) on the Currency enum.

Examples

The enumeration can be created from the three-character currency code:

use iso4217_static::Currency;

const CURRENCY: &str = "USD";

let actual = Currency::try_from(CURRENCY).expect("valid code");
assert_eq!(Currency::UsDollar, actual);
assert_eq!(CURRENCY, actual.as_ref());

Numeric codes are also supported:

use iso4217_static::Currency;

const CURRENCY: u16 = 840;

let actual = Currency::try_from(CURRENCY).expect("valid code");
assert_eq!(Currency::UsDollar, actual);
assert_eq!(CURRENCY, actual as u16);

There are also methods to get the universal currency for a given country (if the country has one):

use iso3166_static::Alpha2;
use iso4217_static::Currency;

let actual = Currency::try_from(Alpha2::UnitedStatesOfAmerica).expect("country");
assert_eq!(Currency::UsDollar, actual);
Commit count: 71

cargo fmt