Struct ss58_registry::TokenAmount
source · pub struct TokenAmount {
pub token: Token,
pub amount: u128,
}
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§
source§impl Clone for TokenAmount
impl Clone for TokenAmount
source§fn clone(&self) -> TokenAmount
fn clone(&self) -> TokenAmount
Returns a copy 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 TokenAmount
impl Debug for TokenAmount
source§impl Display for TokenAmount
impl Display for TokenAmount
source§impl Hash for TokenAmount
impl Hash for TokenAmount
source§impl Ord for TokenAmount
impl Ord for TokenAmount
source§fn cmp(&self, other: &TokenAmount) -> Ordering
fn cmp(&self, other: &TokenAmount) -> Ordering
1.21.0 · 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
source§impl PartialEq for TokenAmount
impl PartialEq for TokenAmount
source§fn 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 ==
.source§impl PartialOrd for TokenAmount
impl PartialOrd for TokenAmount
source§fn partial_cmp(&self, other: &TokenAmount) -> Option<Ordering>
fn partial_cmp(&self, other: &TokenAmount) -> Option<Ordering>
1.0.0 · source§fn 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 moreimpl Eq for TokenAmount
impl StructuralPartialEq for TokenAmount
Auto Trait Implementations§
impl Freeze for TokenAmount
impl RefUnwindSafe for TokenAmount
impl Send for TokenAmount
impl Sync for TokenAmount
impl Unpin for TokenAmount
impl UnwindSafe for TokenAmount
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)