pub struct CurrencyCode(/* private fields */);Expand description
ISO 4217 currency code.
Implementations§
Source§impl CurrencyCode
impl CurrencyCode
Sourcepub fn new(code: impl AsRef<str>) -> Result<Self, PaymentError>
pub fn new(code: impl AsRef<str>) -> Result<Self, PaymentError>
Parses and validates an ISO 4217-style currency code.
§Errors
Returns an error when the code is not exactly three ASCII letters.
Sourcepub fn minor_unit_exponent(&self) -> u8
pub fn minor_unit_exponent(&self) -> u8
Returns the ISO 4217 minor-unit exponent used by common providers.
Sourcepub fn minor_unit_factor(&self) -> i64
pub fn minor_unit_factor(&self) -> i64
Returns the multiplier between major and minor units.
Sourcepub fn format_minor_units(&self, minor: i64) -> String
pub fn format_minor_units(&self, minor: i64) -> String
Formats a minor-unit amount as a provider decimal amount string.
Sourcepub fn minor_units_to_major_integer(
&self,
minor: i64,
) -> Result<i64, PaymentError>
pub fn minor_units_to_major_integer( &self, minor: i64, ) -> Result<i64, PaymentError>
Converts a minor-unit amount into an integer major-unit amount.
§Errors
Returns an error when the minor amount cannot be represented as a whole major unit.
Sourcepub fn major_integer_to_minor_units(
&self,
major: i64,
) -> Result<i64, PaymentError>
pub fn major_integer_to_minor_units( &self, major: i64, ) -> Result<i64, PaymentError>
Converts an integer major-unit amount into minor units.
§Errors
Returns an error when the multiplication overflows.
Trait Implementations§
Source§impl AsRef<str> for CurrencyCode
impl AsRef<str> for CurrencyCode
Source§impl Clone for CurrencyCode
impl Clone for CurrencyCode
Source§fn clone(&self) -> CurrencyCode
fn clone(&self) -> CurrencyCode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CurrencyCode
impl Debug for CurrencyCode
Source§impl Hash for CurrencyCode
impl Hash for CurrencyCode
Source§impl PartialEq for CurrencyCode
impl PartialEq for CurrencyCode
impl Eq for CurrencyCode
impl StructuralPartialEq for CurrencyCode
Auto Trait Implementations§
impl Freeze for CurrencyCode
impl RefUnwindSafe for CurrencyCode
impl Send for CurrencyCode
impl Sync for CurrencyCode
impl Unpin for CurrencyCode
impl UnsafeUnpin for CurrencyCode
impl UnwindSafe for CurrencyCode
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