Trait currencies::currency::Currency
source · pub trait Currency: Copy + Clone + PartialEq + Eq + PartialOrd + Ord + Hash {
type Backing: Backing;
const BASE: Self::Backing;
const CODE: &'static str;
const SYMBOL: &'static str;
const PROPER_NAME: &'static str;
const STYLE: FormatStyle;
const IS_ISO: bool;
const IS_CRYPTO: bool;
// Provided method
fn decimal_digits() -> usize { ... }
}
Required Associated Types§
Required Associated Constants§
sourceconst BASE: Self::Backing
const BASE: Self::Backing
Determines the numerical base of an Amount
of this Currency
.
For base ten currencies, this should be a 1
followed by a number of zeroes
corresponding with the number of supported digits to the right of the decimal place.
Some very rare currencies use a base other than 10, such as Malagasy ariary. For these you should use an appropriate base.
sourceconst CODE: &'static str
const CODE: &'static str
Specifies a 3-4 digit acronym or “code” that can be used as a short name for this
Currency
. For ISO-supported currencies, this will be equal to the ISO-4217
alphabetic code, which can be found here: https://en.wikipedia.org/wiki/ISO_4217.
For cryptocurrencies and other currencies not named in ISO-4217, this should be a short
globally unique code that is specific to the currency, for example BTC
for Bitcoin,
ETH
for Ethereum, etc..
sourceconst SYMBOL: &'static str
const SYMBOL: &'static str
Specifies the monetary symbol, such as $
, that is commonly associated with this
Currency
.
It is worth noting that such symbols can be multiple characters long, are not globally
unique (actually many currencies use the $
symbol and there are plenty examples of
the same symbol being used for many currencies), and are not governed or defined by
ISO-4217 or any other ISO. They also do not have to be symbols, they could be a word or
several words long.
The symbol is used when formatted values of an Amount
using this Currency
are
displayed.
sourceconst PROPER_NAME: &'static str
const PROPER_NAME: &'static str
Specifies a long-hand / “proper” name for this Currency
, for example “United States
Dollar”.
For currencies governed by ISO-4217, this corresponds with the “entity” field.
sourceconst STYLE: FormatStyle
const STYLE: FormatStyle
Specifies how an Amount
of this Currency
should be displayed when it is
represented textually via core::fmt::Display
and core::fmt::Debug
.
Provided Methods§
sourcefn decimal_digits() -> usize
fn decimal_digits() -> usize
Returns the number of digits to the right of the decimal point for this Currency
.