pub struct Amount {
pub minor_units: u64,
pub currency: Currency,
pub exponent: u8,
}Expand description
A monetary amount expressed in minor units (e.g. pence, cents) with a currency and the number of minor-unit decimal places.
The EMVCo spec requires purchaseAmount as a numeric string (max 48 digits)
and purchaseExponent as the number of digits after the decimal point.
Fields§
§minor_units: u64Minor-unit value (e.g. 1099 for £10.99)
currency: Currency§exponent: u8Decimal exponent per ISO 4217 (e.g. 2 for GBP → £X.XX)
Implementations§
Source§impl Amount
impl Amount
pub fn new(minor_units: u64, currency: Currency, exponent: u8) -> Self
Sourcepub fn from_major(major: u64, currency: Currency) -> Self
pub fn from_major(major: u64, currency: Currency) -> Self
Convenience: construct from major units with a 2-digit exponent.
Sourcepub fn spec_amount(&self) -> String
pub fn spec_amount(&self) -> String
EMVCo purchaseAmount field value.
Sourcepub fn spec_currency(&self) -> String
pub fn spec_currency(&self) -> String
EMVCo purchaseCurrency field value.
Sourcepub fn spec_exponent(&self) -> String
pub fn spec_exponent(&self) -> String
EMVCo purchaseExponent field value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Amount
impl<'de> Deserialize<'de> for Amount
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Amount
impl StructuralPartialEq for Amount
Auto Trait Implementations§
impl Freeze for Amount
impl RefUnwindSafe for Amount
impl Send for Amount
impl Sync for Amount
impl Unpin for Amount
impl UnsafeUnpin for Amount
impl UnwindSafe for Amount
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