pub struct Money {
pub minor: i64,
pub currency: String,
}Fields§
§minor: i64Minor units: cents, sen. For IDR the minor unit is the rupiah itself.
currency: StringISO 4217, upper case.
Implementations§
Source§impl Money
impl Money
pub fn new(minor: i64, currency: impl Into<String>) -> Money
Sourcepub fn positive(&self) -> Result<(), Error>
pub fn positive(&self) -> Result<(), Error>
A charge for nothing or for less than nothing is a mistake upstream, and a gateway asked for one answers with an error that names nothing.
pub fn is_zero(&self) -> bool
Sourcepub fn plus(&self, other: &Money) -> Result<Money, Error>
pub fn plus(&self, other: &Money) -> Result<Money, Error>
Add, refusing to mix currencies. Silently adding 100 IDR to 100 USD produces a number that is neither.
pub fn minus(&self, other: &Money) -> Result<Money, Error>
pub fn to_json(&self) -> Json
pub fn from_json(json: &Json) -> Option<Money>
Trait Implementations§
impl Eq for Money
Source§impl Ord for Money
impl Ord for Money
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Money
impl PartialOrd for Money
impl StructuralPartialEq for Money
Auto Trait Implementations§
impl Freeze for Money
impl RefUnwindSafe for Money
impl Send for Money
impl Sync for Money
impl Unpin for Money
impl UnsafeUnpin for Money
impl UnwindSafe for Money
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