pub struct CurrencyDefinition { /* private fields */ }Expand description
How a currency divides into its base unit – reference data, published in versions with the protocol.
subdivisions lists, from the unit down, how many of the next smaller stage one stage contains: [100] for EUR
(euro, cent), [] for JPY, [17, 29] for Galleons (Galleon, Sickle, Knut), [1000000000, 1000000000] for
x-eth (ether, gwei, wei). Stage n is the unit after n subdivisions; stage 0 is the unit itself, the last
stage the base unit. Names are not part of a definition: translation data names stage n by the key
<code>/<n> (EUR/0 euro, EUR/1 cent).
Implementations§
Source§impl CurrencyDefinition
impl CurrencyDefinition
Sourcepub fn new(
code: Currency,
subdivisions: Vec<u64>,
) -> Result<Self, DefinitionError>
pub fn new( code: Currency, subdivisions: Vec<u64>, ) -> Result<Self, DefinitionError>
A definition, checked: every subdivision between 2 and 2^53 − 1, at most 10^38 base units per unit, and an ISO 4217 currency divided at most once, by a power of ten.
Sourcepub fn subdivisions(&self) -> &[u64]
pub fn subdivisions(&self) -> &[u64]
How many of the next smaller stage each stage contains, from the unit down.
Sourcepub fn base_units_per_unit(&self) -> Option<u128>
pub fn base_units_per_unit(&self) -> Option<u128>
How many base units make one unit: 100 for EUR, 17 · 29 = 493 for Galleons in Knuts; None above 10^38.
Trait Implementations§
Source§impl Clone for CurrencyDefinition
impl Clone for CurrencyDefinition
Source§fn clone(&self) -> CurrencyDefinition
fn clone(&self) -> CurrencyDefinition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more