Struct fvm::kernel::prelude::TokenAmount
source · pub struct TokenAmount { /* private fields */ }
Expand description
A quantity of native tokens. A token amount is an integer, but has a human interpretation as a value with 18 decimal places. This is a new-type in order to prevent accidental conversion from other BigInts. From/Into BigInt is missing by design.
Implementations§
source§impl TokenAmount
impl TokenAmount
sourcepub fn from_atto(atto: impl Into<BigInt>) -> TokenAmount
pub fn from_atto(atto: impl Into<BigInt>) -> TokenAmount
Creates a token amount from a quantity of indivisible units (10^-18 whole units).
sourcepub fn from_nano(nano: impl Into<BigInt>) -> TokenAmount
pub fn from_nano(nano: impl Into<BigInt>) -> TokenAmount
Creates a token amount from nanoFIL.
sourcepub fn from_whole(tokens: impl Into<BigInt>) -> TokenAmount
pub fn from_whole(tokens: impl Into<BigInt>) -> TokenAmount
Creates a token amount from a quantity of whole units (10^18 indivisible units).
pub fn is_zero(&self) -> bool
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
source§impl TokenAmount
impl TokenAmount
pub fn div_rem(&self, other: impl Into<BigInt>) -> (TokenAmount, TokenAmount)
pub fn div_ceil(&self, other: impl Into<BigInt>) -> TokenAmount
pub fn div_floor(&self, other: impl Into<BigInt>) -> TokenAmount
Trait Implementations§
source§impl<'a, 'b> Add<&'b TokenAmount> for &'a TokenAmount
impl<'a, 'b> Add<&'b TokenAmount> for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§fn add(self, other: &'b TokenAmount) -> TokenAmount
fn add(self, other: &'b TokenAmount) -> TokenAmount
Performs the
+
operation. Read moresource§impl<'b> Add<&'b TokenAmount> for TokenAmount
impl<'b> Add<&'b TokenAmount> for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§fn add(self, other: &'b TokenAmount) -> TokenAmount
fn add(self, other: &'b TokenAmount) -> TokenAmount
Performs the
+
operation. Read moresource§impl<'a> Add<TokenAmount> for &'a TokenAmount
impl<'a> Add<TokenAmount> for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§fn add(self, other: TokenAmount) -> TokenAmount
fn add(self, other: TokenAmount) -> TokenAmount
Performs the
+
operation. Read moresource§impl Add for TokenAmount
impl Add for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§fn add(self, other: TokenAmount) -> TokenAmount
fn add(self, other: TokenAmount) -> TokenAmount
Performs the
+
operation. Read moresource§impl<'a> AddAssign<&'a TokenAmount> for TokenAmount
impl<'a> AddAssign<&'a TokenAmount> for TokenAmount
source§fn add_assign(&mut self, other: &TokenAmount)
fn add_assign(&mut self, other: &TokenAmount)
Performs the
+=
operation. Read moresource§impl AddAssign for TokenAmount
impl AddAssign for TokenAmount
source§fn add_assign(&mut self, other: TokenAmount)
fn add_assign(&mut self, other: TokenAmount)
Performs the
+=
operation. Read moresource§impl Arbitrary for TokenAmount
impl Arbitrary for TokenAmount
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 Default for TokenAmount
impl Default for TokenAmount
source§fn default() -> TokenAmount
fn default() -> TokenAmount
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for TokenAmount
impl<'de> Deserialize<'de> for TokenAmount
source§fn deserialize<D>(
deserializer: D,
) -> Result<TokenAmount, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<TokenAmount, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for TokenAmount
impl Display for TokenAmount
Displays a token amount as a decimal in human units. To avoid any confusion over whether the value is in human-scale or indivisible units, the display always includes a decimal point.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(v: TokenAmount) -> TokenAmount
fn from(v: TokenAmount) -> TokenAmount
Converts to this type from the input type.
source§impl Hash for TokenAmount
impl Hash for TokenAmount
source§impl<'a, 'b> Mul<&'b TokenAmount> for &'a BigInt
impl<'a, 'b> Mul<&'b TokenAmount> for &'a BigInt
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§fn mul(self, other: &'b TokenAmount) -> TokenAmount
fn mul(self, other: &'b TokenAmount) -> TokenAmount
Performs the
*
operation. Read moresource§impl<'b> Mul<&'b TokenAmount> for BigInt
impl<'b> Mul<&'b TokenAmount> for BigInt
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§fn mul(self, other: &'b TokenAmount) -> TokenAmount
fn mul(self, other: &'b TokenAmount) -> TokenAmount
Performs the
*
operation. Read moresource§impl<'a, T> Mul<T> for &'a TokenAmount
impl<'a, T> Mul<T> for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§impl<T> Mul<T> for TokenAmount
impl<T> Mul<T> for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§impl<'a> Mul<TokenAmount> for &'a BigInt
impl<'a> Mul<TokenAmount> for &'a BigInt
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§fn mul(self, other: TokenAmount) -> TokenAmount
fn mul(self, other: TokenAmount) -> TokenAmount
Performs the
*
operation. Read moresource§impl Mul<TokenAmount> for BigInt
impl Mul<TokenAmount> for BigInt
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
*
operator.source§fn mul(self, other: TokenAmount) -> TokenAmount
fn mul(self, other: TokenAmount) -> TokenAmount
Performs the
*
operation. Read moresource§impl<T> MulAssign<T> for TokenAmount
impl<T> MulAssign<T> for TokenAmount
source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
Performs the
*=
operation. Read moresource§impl<'a> Neg for &'a TokenAmount
impl<'a> Neg for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn neg(self) -> TokenAmount
fn neg(self) -> TokenAmount
Performs the unary
-
operation. Read moresource§impl Neg for TokenAmount
impl Neg for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn neg(self) -> TokenAmount
fn neg(self) -> TokenAmount
Performs the unary
-
operation. Read moresource§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 moresource§impl Serialize for TokenAmount
impl Serialize for TokenAmount
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl<'a, 'b> Sub<&'b TokenAmount> for &'a TokenAmount
impl<'a, 'b> Sub<&'b TokenAmount> for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn sub(self, other: &'b TokenAmount) -> TokenAmount
fn sub(self, other: &'b TokenAmount) -> TokenAmount
Performs the
-
operation. Read moresource§impl<'b> Sub<&'b TokenAmount> for TokenAmount
impl<'b> Sub<&'b TokenAmount> for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn sub(self, other: &'b TokenAmount) -> TokenAmount
fn sub(self, other: &'b TokenAmount) -> TokenAmount
Performs the
-
operation. Read moresource§impl<'a> Sub<TokenAmount> for &'a TokenAmount
impl<'a> Sub<TokenAmount> for &'a TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn sub(self, other: TokenAmount) -> TokenAmount
fn sub(self, other: TokenAmount) -> TokenAmount
Performs the
-
operation. Read moresource§impl Sub for TokenAmount
impl Sub for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§fn sub(self, other: TokenAmount) -> TokenAmount
fn sub(self, other: TokenAmount) -> TokenAmount
Performs the
-
operation. Read moresource§impl<'a> SubAssign<&'a TokenAmount> for TokenAmount
impl<'a> SubAssign<&'a TokenAmount> for TokenAmount
source§fn sub_assign(&mut self, other: &TokenAmount)
fn sub_assign(&mut self, other: &TokenAmount)
Performs the
-=
operation. Read moresource§impl SubAssign for TokenAmount
impl SubAssign for TokenAmount
source§fn sub_assign(&mut self, other: TokenAmount)
fn sub_assign(&mut self, other: TokenAmount)
Performs the
-=
operation. Read moresource§impl<'a> Sum<&'a TokenAmount> for TokenAmount
impl<'a> Sum<&'a TokenAmount> for TokenAmount
source§fn sum<I>(iter: I) -> TokenAmountwhere
I: Iterator<Item = &'a TokenAmount>,
fn sum<I>(iter: I) -> TokenAmountwhere
I: Iterator<Item = &'a TokenAmount>,
Method which takes an iterator and generates
Self
from the elements by
“summing up” the items.source§impl Sum for TokenAmount
impl Sum for TokenAmount
source§fn sum<I>(iter: I) -> TokenAmountwhere
I: Iterator<Item = TokenAmount>,
fn sum<I>(iter: I) -> TokenAmountwhere
I: Iterator<Item = TokenAmount>,
Method which takes an iterator and generates
Self
from the elements by
“summing up” the items.source§impl Zero for TokenAmount
impl Zero for TokenAmount
impl 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
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> References<RawCodec> for T
impl<T> References<RawCodec> for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.