pub struct Currency { /* private fields */ }Expand description
Represents a currency set used in the CDR.
Implementations§
Source§impl Currency
impl Currency
Sourcepub fn currency_code(&self) -> CurrencyCode
pub fn currency_code(&self) -> CurrencyCode
Gets the CurrencyCode.
Sourcepub fn exponent(&self) -> i32
pub fn exponent(&self) -> i32
Gets the Currency exponent.
Used to get the real value of a denomination by raising 10 to the exponent, and multiplying by the denomination amount.
Sourcepub fn to_mdu_value(&self, value: u32) -> u32
pub fn to_mdu_value(&self, value: u32) -> u32
Converts a standard value to a MDU value.
Example:
let value = 10;
let currency = Currency::from(CurrencyCode::from("USD"));
assert_eq!(currency.to_mdu_value(value), 1000);Sourcepub fn from_mdu_value(&self, value: u32) -> u32
pub fn from_mdu_value(&self, value: u32) -> u32
Converts a MDU value to a standard value.
Example:
let mdu_value = 1000;
let currency = Currency::from(CurrencyCode::from("USD"));
assert_eq!(currency.from_mdu_value(mdu_value), 10);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Currency
impl<'de> Deserialize<'de> for Currency
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Currency, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Currency, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<CurrencyCode> for Currency
impl From<CurrencyCode> for Currency
Source§fn from(val: CurrencyCode) -> Currency
fn from(val: CurrencyCode) -> Currency
Converts to this type from the input type.
Source§impl Serialize for Currency
impl Serialize for Currency
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Currency
impl StructuralPartialEq for Currency
Auto Trait Implementations§
impl Freeze for Currency
impl RefUnwindSafe for Currency
impl Send for Currency
impl Sync for Currency
impl Unpin for Currency
impl UnwindSafe for Currency
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more