Struct forest_filecoin::shim::econ::TokenAmount
source · pub struct TokenAmount(TokenAmount);
Tuple Fields§
§0: TokenAmount
Implementations§
source§impl TokenAmount
impl TokenAmount
pub fn from_atto(atto: impl Into<BigInt>) -> Self
pub fn from_nano(nano: impl Into<BigInt>) -> Self
pub fn from_whole(fil: impl Into<BigInt>) -> Self
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
Methods from Deref<Target = TokenAmount_latest>§
pub const DECIMALS: usize = 18usize
pub const PRECISION: u64 = 1_000_000_000_000_000_000u64
pub fn is_zero(&self) -> bool
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
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 Add<&TokenAmount> for &TokenAmount
impl Add<&TokenAmount> for &TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§impl Add<&TokenAmount> for TokenAmount
impl Add<&TokenAmount> for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§impl Add<TokenAmount> for &TokenAmount
impl Add<TokenAmount> for &TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§impl Add for TokenAmount
impl Add for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
+
operator.source§impl AddAssign for TokenAmount
impl AddAssign for TokenAmount
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moresource§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 Deref for TokenAmount
impl Deref for TokenAmount
source§impl DerefMut for TokenAmount
impl DerefMut for TokenAmount
source§impl<'de> Deserialize<'de> for TokenAmount
impl<'de> Deserialize<'de> for TokenAmount
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for TokenAmount
impl Display for TokenAmount
source§impl From<&TokenAmount> for EthBigInt
impl From<&TokenAmount> for EthBigInt
source§fn from(amount: &TokenAmount) -> Self
fn from(amount: &TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for Pretty
impl From<&TokenAmount> for Pretty
source§fn from(value: &TokenAmount) -> Self
fn from(value: &TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount) -> Self
fn from(other: &TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount_v2) -> Self
fn from(other: &TokenAmount_v2) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount_v4) -> Self
fn from(other: &TokenAmount_v4) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount) -> Self
fn from(other: &TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount_v3) -> Self
fn from(other: &TokenAmount_v3) -> Self
Converts to this type from the input type.
source§impl From<&TokenAmount> for TokenAmount
impl From<&TokenAmount> for TokenAmount
source§fn from(other: &TokenAmount) -> Self
fn from(other: &TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<BigInt> for TokenAmount
impl From<BigInt> for TokenAmount
source§impl From<TokenAmount> for BigInt
impl From<TokenAmount> for BigInt
source§fn from(value: TokenAmount) -> Self
fn from(value: TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for EthBigInt
impl From<TokenAmount> for EthBigInt
source§fn from(amount: TokenAmount) -> Self
fn from(amount: TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount_v2) -> Self
fn from(other: TokenAmount_v2) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount_v4) -> Self
fn from(other: TokenAmount_v4) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount) -> Self
fn from(other: TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount_v3) -> Self
fn from(other: TokenAmount_v3) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount) -> Self
fn from(other: TokenAmount) -> Self
Converts to this type from the input type.
source§impl From<TokenAmount> for TokenAmount
impl From<TokenAmount> for TokenAmount
source§fn from(other: TokenAmount) -> Self
fn from(other: TokenAmount) -> Self
Converts to this type from the input type.
source§impl HasLotusJson for TokenAmount
impl HasLotusJson for TokenAmount
§type LotusJson = TokenAmountLotusJson
type LotusJson = TokenAmountLotusJson
The struct representing JSON. You should
#[derive(Deserialize, Serialize)]
on it.fn into_lotus_json(self) -> Self::LotusJson
fn from_lotus_json(lotus_json: Self::LotusJson) -> Self
fn into_lotus_json_value(self) -> Result<Value>
fn into_lotus_json_string(self) -> Result<String>
fn into_lotus_json_string_pretty(self) -> Result<String>
source§impl Hash for TokenAmount
impl Hash for TokenAmount
source§impl Mul<BigInt> for &TokenAmount
impl Mul<BigInt> for &TokenAmount
source§impl Mul<BigInt> for TokenAmount
impl Mul<BigInt> for TokenAmount
source§impl Mul<i64> for &TokenAmount
impl Mul<i64> for &TokenAmount
source§impl Mul<i64> for TokenAmount
impl Mul<i64> for TokenAmount
source§impl Mul<u64> for &TokenAmount
impl Mul<u64> for &TokenAmount
source§impl Mul<u64> for TokenAmount
impl Mul<u64> for TokenAmount
source§impl MulAssign<BigInt> for TokenAmount
impl MulAssign<BigInt> for TokenAmount
source§fn mul_assign(&mut self, rhs: BigInt)
fn mul_assign(&mut self, rhs: BigInt)
Performs the
*=
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§impl Sub<&TokenAmount> for TokenAmount
impl Sub<&TokenAmount> for TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§impl Sub<TokenAmount> for &TokenAmount
impl Sub<TokenAmount> for &TokenAmount
§type Output = TokenAmount
type Output = TokenAmount
The resulting type after applying the
-
operator.source§impl SubAssign for TokenAmount
impl SubAssign for TokenAmount
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read moresource§impl TokenAmountPretty for TokenAmount
impl TokenAmountPretty for TokenAmount
source§fn pretty(&self) -> Pretty
fn pretty(&self) -> Pretty
Note the following format specifiers:
{:#}
: print number of FIL, not e.gmilliFIL
{:.4}
: round to 4 significant figures{:.#4}
: both
let amount = TokenAmount::from_nano(1500);
// Defaults to precise, with SI prefix
assert_eq!("1500 nanoFIL", format!("{}", amount.pretty()));
// Rounded to 1 s.f
assert_eq!("~2 microFIL", format!("{:.1}", amount.pretty()));
// Show absolute FIL
assert_eq!("0.0000015 FIL", format!("{:#}", amount.pretty()));
// Rounded absolute FIL
assert_eq!("~0.000002 FIL", format!("{:#.1}", amount.pretty()));
// We only indicate lost precision when relevant
assert_eq!("1500 nanoFIL", format!("{:.2}", amount.pretty()));
§Formatting
- We select the most diminutive SI prefix (or not!) that allows us to display an integer amount.
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<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§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§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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
source§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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.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.