Struct ss58_registry::TokenAmount
source · [−]Expand description
A given amount of token. Can be used for nicely formatted output and token-aware comparison of different amounts.
let token = Token { name: "I❤U", decimals: 8 };
let my_amount = token.amount(100_000_000_000);
assert_eq!(format!("{}", my_amount), "1,000.000 I❤U");
assert_eq!(format!("{:?}", my_amount), "1000.000 I❤U (100,000,000,000)");
Fields
token: Token
The token this amount is from.
amount: u128
The amount in the smallest granularity of the token.
Trait Implementations
sourceimpl Clone for TokenAmount
impl Clone for TokenAmount
sourcefn clone(&self) -> TokenAmount
fn clone(&self) -> TokenAmount
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TokenAmount
impl Debug for TokenAmount
sourceimpl Display for TokenAmount
impl Display for TokenAmount
sourceimpl Hash for TokenAmount
impl Hash for TokenAmount
sourceimpl Ord for TokenAmount
impl Ord for TokenAmount
sourceimpl PartialEq<TokenAmount> for TokenAmount
impl PartialEq<TokenAmount> for TokenAmount
sourcefn eq(&self, other: &TokenAmount) -> bool
fn eq(&self, other: &TokenAmount) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TokenAmount) -> bool
fn ne(&self, other: &TokenAmount) -> bool
This method tests for !=
.
sourceimpl PartialOrd<TokenAmount> for TokenAmount
impl PartialOrd<TokenAmount> for TokenAmount
sourcefn partial_cmp(&self, other: &TokenAmount) -> Option<Ordering>
fn partial_cmp(&self, other: &TokenAmount) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for TokenAmount
impl StructuralEq for TokenAmount
impl StructuralPartialEq for TokenAmount
Auto Trait Implementations
impl RefUnwindSafe for TokenAmount
impl Send for TokenAmount
impl Sync for TokenAmount
impl Unpin for TokenAmount
impl UnwindSafe for TokenAmount
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more