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§
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<TokenAmount> for TokenAmount
impl PartialEq<TokenAmount> for TokenAmount
source§fn eq(&self, other: &TokenAmount) -> bool
fn eq(&self, other: &TokenAmount) -> bool
source§impl PartialOrd<TokenAmount> for TokenAmount
impl PartialOrd<TokenAmount> 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 more