Crate codes_iso_4217

source ·
Expand description

This package contains an implementation of the ISO 4217 Currency Codes specification.

This standard establishes internationally recognized codes for the representation of currencies that enable clarity and reduce errors. Currencies are represented both numerically and alphabetically, using either three digits or three letters. Some of the alphabetic codes for major currencies are familiar, such as “EUR” for Euros. Fortunately, ISO 4217 covers everything from Afghanis to Zambian Kwacha as well.

This package extends the data model of the ISO specification by adding a currency symbol string (and Unicode code points for the symbol) where possible to all symbols.

Example

use codes_iso_4217::{CurrencyCode, ISO_4217};

let code = CurrencyCode::BZD;

assert_eq!(code.alpha_code(), "BZD");
assert_eq!(code.numeric_code(), Some(84));

// feature = "currency_name"
// assert_eq!(code.currency_name(), "Belize Dollar");

// feature = "country_name"
// assert_eq!(code.country_name(), "BELIZE");

// feature = "monetary_units"
// assert_eq!(code.monetary_units(), 2);

// feature = "is_fund"
// assert_eq!(code.is_fund(), false);

// feature = "historical_codes"
// assert_eq!(code.is_historical(), false);
// assert_eq!(code.withdrawal_date(), None);

// feature = "symbols"
// assert_eq!(code.currency_symbol_str(), Some("BZ$"));
// assert_eq!(code.currency_symbol_code_points(), Some(&[0x42, 0x5a, 0x24]));

assert_eq!(ISO_4217.title(), "Currency codes");

Features

By default only the serde feature is enabled, the CurrencyCode::alpha_code and CurrencyCode::numeric_code methods cannot be excluded.

Enums

This type represents The codes defined in the ISO 4127 standard and the implementations included are generated from ISO’s own public data files.
Common Error type, mainly used for FromStr failures.

Constants

The publication date of the list-one file used to generate active entries.
Provides an array of all defined CurrencyCode codes, useful for queries.
The publication date of the list-three file used to generate historical entries.
An instance of the Standard struct defined in the codes_agency package that describes the ISO-4217 specification.