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 moresourceimpl 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
sourcefn cmp(&self, other: &TokenAmount) -> Ordering
fn cmp(&self, other: &TokenAmount) -> Ordering
1.21.0 · sourcefn 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 · sourcefn 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
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<TokenAmount> for TokenAmount
impl PartialEq<TokenAmount> for TokenAmount
sourcefn eq(&self, other: &TokenAmount) -> bool
fn eq(&self, other: &TokenAmount) -> bool
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>
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 moreimpl 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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