Static ISO 4217 Currency Data
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 theserdefeature.serde: Enables serialization/deserialization usingserde.alloc: Enables the use of allocated types (this should be enabled ifserdeis enabled).zerocopy: Enables the derivation ofzerocopytraits (specifically,TryFromBytesandIntoBytes) on theCurrencyenum.
Examples
The enumeration can be created from the three-character currency code:
use Currency;
const CURRENCY: &str = "USD";
let actual = try_from.expect;
assert_eq!;
assert_eq!;
Numeric codes are also supported:
use Currency;
const CURRENCY: u16 = 840;
let actual = try_from.expect;
assert_eq!;
assert_eq!;
There are also methods to get the universal currency for a given country (if the country has one):
use Alpha2;
use Currency;
let actual = try_from.expect;
assert_eq!;