Skip to main content

Amount

Struct Amount 

Source
pub struct Amount(/* private fields */);
Expand description

A 128-bit signed amount.

This is a general purpose signed integer, but is primarily used to represent the smallest unit of value in resources/vaults etc.

This allows Tari to support a massive number tokens within resources. e.g. 2 ETH = 2 x 10^18 Gwei.

Implementations§

Source§

impl Amount

Source

pub const BITS: usize

Source

pub const BYTE_SIZE: usize

Source

pub const MAX: Amount

The maximum value that an Amount can hold.

Source

pub const MIN: Amount

The minimum value that an Amount can hold.

Source

pub const NUM_U64_DIGITS: usize

The number of u64 digits used to represent a Amount i.e. 2

Source

pub const ONE: Amount

The value of one, represented as an Amount.

Source

pub const ONE_HUNDRED: Amount

The value of one hundred, represented as an Amount.

Source

pub const ONE_THOUSAND: Amount

The value of one thousand, represented as an Amount.

Source

pub const TEN: Amount

The value of ten, represented as an Amount.

Source

pub const ZERO: Amount

The value of zero, represented as an Amount.

Source

pub const fn new(amount: u128) -> Amount

Creates a new Amount from an integer value.

Source

pub fn from_integer<T>(amount: T) -> Amount
where T: Into<u128>,

Creates a new Amount from an integer value.

Source

pub const fn from_usize(value: usize) -> Amount

Source

pub const fn zero() -> Amount

A value of zero.

Source

pub const fn is_zero(&self) -> bool

Returns true if the amount is zero.

Source

pub const fn is_positive(&self) -> bool

Returns true if the amount is positive (greater than zero).

Source

pub const fn is_negative(&self) -> bool

Always returns false since this type cannot represent negative values. This method is provided for symmetry with other amount types that may be signed.

Source

pub const fn from_u64(value: u64) -> Amount

Source

pub const fn to_u128(&self) -> u128

Source

pub const fn checked_add(&self, other: Amount) -> Option<Amount>

Returns the value of this amount + other. Returns None if the result underflows or overflows.

Source

pub const fn saturating_add(&self, other: Amount) -> Amount

Returns the sum of two amounts, saturating at i64::MAX if the result exceeds it.

Source

pub const fn checked_sub(&self, other: Amount) -> Option<Amount>

Returns the difference of two amounts, saturating at 0 if the result is negative.

Source

pub fn sum_from_positive<A, I>(iter: I) -> Option<Amount>
where A: Into<Amount>, I: Iterator<Item = A>,

Source

pub const fn saturating_sub(&self, other: Amount) -> Amount

Returns the difference of two amounts, saturating at Amount::MIN if the result underflows. If negative results are not desired, use saturating_sub_positive.

Source

pub const fn checked_mul(&self, other: Amount) -> Option<Amount>

Returns the product of two amounts, returning None if the result overflows.

Source

pub const fn saturating_mul(&self, other: Amount) -> Amount

Returns the product of two amounts, saturating at i64::MAX if the result exceeds it.

Source

pub const fn checked_div(&self, other: Amount) -> Option<Amount>

Returns the quotient of two amounts, returning None if the divisor is zero or if the result overflows.

Source

pub const fn checked_div_ceil(&self, other: Amount) -> Option<Amount>

Returns the quotient of two amounts, returning None if the divisor is zero or if the result overflows.

Source

pub const fn div_ceil(&self, other: Amount) -> Amount

Returns the quotient of two amounts, returning None if the divisor is zero or if the result overflows.

§Panics

If the divisor is zero, this function will panic.

Source

pub const fn saturating_div(&self, other: &Amount) -> Amount

Returns the quotient of two amounts, saturating at i64::MAX if the result exceeds it.

Source

pub fn to_u64_checked(&self) -> Option<u64>

Returns the value as an u64 if possible, otherwise returns None. Since the internal representation is i64, this will return None if the value is negative.

Source

pub fn to_canonical_bytes(&self) -> [u8; 16]

Returns the value as an BYTE_SIZE byte array in canonical order (little-endian).

Source

pub fn to_le_bytes(&self) -> [u8; 16]

Source

pub fn from_le_bytes(bytes: [u8; 16]) -> Amount

Source

pub const fn from_le_digits(digits: [u64; 2]) -> Amount

Source

pub fn from_le_slice(bytes: &[u8]) -> Option<Amount>

Creates an integer value from a slice of bytes in little endian. The value is wrapped in an Option as the bytes may represent an integer too large to be represented by the type.

If the length of the slice is shorter than Self::BYTES, the slice is padded with zeros or ones at the end so that it’s length equals Self::BYTES.

If the length of the slice is longer than Self::BYTES, None will be returned, unless the bytes have trailing zeros that can be removed until the length of the slice equals Self::BYTES.

Source

pub fn to_le_digits(&self) -> [u64; 2]

Source

pub fn non_negative_checked(self) -> Option<Amount>

If the amount is negative (< 0), returns None, otherwise returns Some(self).

Source

pub fn negative_checked(self) -> Option<Amount>

If the amount is positive (> 0), returns None, otherwise returns Some(self).

Source

pub const fn pow(&self, exp: u32) -> Amount

Returns the amount raised to the power of exp.

Source

pub const fn checked_pow(&self, exp: u32) -> Option<Amount>

Returns the amount raised to the power of exp, returning None if the result overflows.

Source

pub const fn try_from_str_radix(s: &str, radix: u32) -> Option<Amount>

Parses a string as an Amount in the specified radix.

This function works in constant context, allowing it to be used to define constants.

Source

pub const fn from_str_radix(s: &str, radix: u32) -> Amount

Parses a string as an Amount in the specified radix.

§Panics

Panics if string parsing fails

Source

pub fn to_decimal_string(&self, decimals: u32) -> String

Formats the amount as a decimal string with the specified number of decimal places.

§Panics

Panics if decimals is greater than 57.

Source

pub fn fmt_decimals<F>(&self, f: &mut F, decimals: u32) -> Result<(), Error>
where F: Write,

Trait Implementations§

Source§

impl Add<u64> for Amount

Source§

type Output = Amount

The resulting type after applying the + operator.
Source§

fn add(self, other: u64) -> <Amount as Add<u64>>::Output

Performs the + operation. Read more
Source§

impl Add for Amount

Source§

type Output = Amount

The resulting type after applying the + operator.
Source§

fn add(self, other: Amount) -> Amount

Performs the + operation. Read more
Source§

impl AddAssign for Amount

Source§

fn add_assign(&mut self, other: Amount)

Performs the += operation. Read more
Source§

impl Clone for Amount

Source§

fn clone(&self) -> Amount

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Amount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Amount

Source§

fn default() -> Amount

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Amount

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Amount, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Amount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div<u64> for Amount

Source§

type Output = Amount

The resulting type after applying the / operator.
Source§

fn div(self, other: u64) -> <Amount as Div<u64>>::Output

Performs the / operation. Read more
Source§

impl Div for Amount

Source§

type Output = Amount

The resulting type after applying the / operator.
Source§

fn div(self, other: Amount) -> Amount

Performs the / operation. Read more
Source§

impl DivAssign for Amount

Source§

fn div_assign(&mut self, other: Amount)

Performs the /= operation. Read more
Source§

impl From<u128> for Amount

Source§

fn from(value: u128) -> Amount

Converts to this type from the input type.
Source§

impl From<u16> for Amount

Source§

fn from(value: u16) -> Amount

Converts to this type from the input type.
Source§

impl From<u32> for Amount

Source§

fn from(value: u32) -> Amount

Converts to this type from the input type.
Source§

impl From<u64> for Amount

Source§

fn from(value: u64) -> Amount

Converts to this type from the input type.
Source§

impl From<u8> for Amount

Source§

fn from(value: u8) -> Amount

Converts to this type from the input type.
Source§

impl FromStr for Amount

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Amount, <Amount as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Amount

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<u64> for Amount

Source§

type Output = Amount

The resulting type after applying the * operator.
Source§

fn mul(self, other: u64) -> <Amount as Mul<u64>>::Output

Performs the * operation. Read more
Source§

impl Mul for Amount

Source§

type Output = Amount

The resulting type after applying the * operator.
Source§

fn mul(self, other: Amount) -> Amount

Performs the * operation. Read more
Source§

impl MulAssign for Amount

Source§

fn mul_assign(&mut self, other: Amount)

Performs the *= operation. Read more
Source§

impl Ord for Amount

Source§

fn cmp(&self, other: &Amount) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<i128> for Amount

Source§

fn eq(&self, other: &i128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i16> for Amount

Source§

fn eq(&self, other: &i16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i32> for Amount

Source§

fn eq(&self, other: &i32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i64> for Amount

Source§

fn eq(&self, other: &i64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i8> for Amount

Source§

fn eq(&self, other: &i8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<isize> for Amount

Source§

fn eq(&self, other: &isize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u128> for Amount

Source§

fn eq(&self, other: &u128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u16> for Amount

Source§

fn eq(&self, other: &u16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u32> for Amount

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u64> for Amount

Source§

fn eq(&self, other: &u64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u8> for Amount

Source§

fn eq(&self, other: &u8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<usize> for Amount

Source§

fn eq(&self, other: &usize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Amount

Source§

fn eq(&self, other: &Amount) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<i128> for Amount

Source§

fn partial_cmp(&self, other: &i128) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i16> for Amount

Source§

fn partial_cmp(&self, other: &i16) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i32> for Amount

Source§

fn partial_cmp(&self, other: &i32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i64> for Amount

Source§

fn partial_cmp(&self, other: &i64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i8> for Amount

Source§

fn partial_cmp(&self, other: &i8) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u128> for Amount

Source§

fn partial_cmp(&self, other: &u128) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u16> for Amount

Source§

fn partial_cmp(&self, other: &u16) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u32> for Amount

Source§

fn partial_cmp(&self, other: &u32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u64> for Amount

Source§

fn partial_cmp(&self, other: &u64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u8> for Amount

Source§

fn partial_cmp(&self, other: &u8) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<usize> for Amount

Source§

fn partial_cmp(&self, other: &usize) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Amount

Source§

fn partial_cmp(&self, other: &Amount) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem for Amount

Source§

type Output = Amount

The resulting type after applying the % operator.
Source§

fn rem(self, other: Amount) -> Amount

Performs the % operation. Read more
Source§

impl RemAssign for Amount

Source§

fn rem_assign(&mut self, other: Amount)

Performs the %= operation. Read more
Source§

impl Serialize for Amount

Source§

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 Sub<u64> for Amount

Source§

type Output = Amount

The resulting type after applying the - operator.
Source§

fn sub(self, other: u64) -> <Amount as Sub<u64>>::Output

Performs the - operation. Read more
Source§

impl Sub for Amount

Source§

type Output = Amount

The resulting type after applying the - operator.
Source§

fn sub(self, other: Amount) -> Amount

Performs the - operation. Read more
Source§

impl SubAssign for Amount

Source§

fn sub_assign(&mut self, other: Amount)

Performs the -= operation. Read more
Source§

impl Sum for Amount

Source§

fn sum<I>(iter: I) -> Amount
where I: Iterator<Item = Amount>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<Amount> for usize

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Amount) -> Result<usize, <usize as TryFrom<Amount>>::Error>

Performs the conversion.
Source§

impl TryFrom<i128> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i128) -> Result<Amount, <Amount as TryFrom<i128>>::Error>

Performs the conversion.
Source§

impl TryFrom<i16> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i16) -> Result<Amount, <Amount as TryFrom<i16>>::Error>

Performs the conversion.
Source§

impl TryFrom<i32> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i32) -> Result<Amount, <Amount as TryFrom<i32>>::Error>

Performs the conversion.
Source§

impl TryFrom<i64> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i64) -> Result<Amount, <Amount as TryFrom<i64>>::Error>

Performs the conversion.
Source§

impl TryFrom<i8> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i8) -> Result<Amount, <Amount as TryFrom<i8>>::Error>

Performs the conversion.
Source§

impl TryFrom<isize> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: isize) -> Result<Amount, <Amount as TryFrom<isize>>::Error>

Performs the conversion.
Source§

impl TryFrom<usize> for Amount

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: usize) -> Result<Amount, <Amount as TryFrom<usize>>::Error>

Performs the conversion.
Source§

impl Copy for Amount

Source§

impl Eq for Amount

Source§

impl StructuralPartialEq for Amount

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,