pub struct Money<C: Currency> { /* private fields */ }Expand description
Amount of currency C with exact decimal arithmetic.
Cross-currency Add is a compile error (different C).
Implementations§
Source§impl<C: Currency> Money<C>
impl<C: Currency> Money<C>
Sourcepub fn try_new(amount: Decimal) -> Result<Self, DomainError>
pub fn try_new(amount: Decimal) -> Result<Self, DomainError>
Builds money rounded to the currency scale.
Sourcepub fn try_from_str(s: impl AsRef<str>) -> Result<Self, DomainError>
pub fn try_from_str(s: impl AsRef<str>) -> Result<Self, DomainError>
Parses from a decimal string (no float).
Trait Implementations§
impl<C: Copy + Currency> Copy for Money<C>
Source§impl<'de, C: Currency> Deserialize<'de> for Money<C>
impl<'de, C: Currency> Deserialize<'de> for Money<C>
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<C: Eq + Currency> Eq for Money<C>
impl<C: PartialEq + Currency> StructuralPartialEq for Money<C>
Auto Trait Implementations§
impl<C> Freeze for Money<C>
impl<C> RefUnwindSafe for Money<C>where
C: RefUnwindSafe,
impl<C> Send for Money<C>
impl<C> Sync for Money<C>
impl<C> Unpin for Money<C>where
C: Unpin,
impl<C> UnsafeUnpin for Money<C>
impl<C> UnwindSafe for Money<C>where
C: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP