Skip to main content

Amount

Struct Amount 

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

An amount.

The Amount type can be used to express Bitcoin amounts that support arithmetic and conversion to various denominations. The Amount type does not implement serde traits but we do provide modules for serializing as satoshis or bitcoin.

Warning!

This type implements several arithmetic operations from core::ops. To prevent errors due to an overflow when using these operations, it is advised to instead use the checked arithmetic methods whose names start with checked_. The operations from core::ops that Amount implements will panic when an overflow occurs.

§Examples

use serde::{Serialize, Deserialize};
use bitcoin_units::Amount;

#[derive(Serialize, Deserialize)]
struct Foo {
    // If you are using `rust-bitcoin` then `bitcoin::amount::serde::as_sat` also works.
    #[serde(with = "bitcoin_units::amount::serde::as_sat")]  // Also `serde::as_btc`.
    amount: Amount,
}

Implementations§

Source§

impl Amount

Source

pub const MAX: Self

The maximum value of an amount.

Source

pub const MIN: Self

The minimum value of an amount.

Source

pub const fn to_sat(self) -> u64

Gets the number of satoshis in this Amount.

§Examples
assert_eq!(Amount::ONE_BTC.to_sat(), 100_000_000);
Source

pub const fn from_sat(satoshi: u64) -> Result<Self, OutOfRangeError>

Constructs a new Amount from the given number of satoshis.

§Errors

If satoshi is outside of valid range (greater than Self::MAX_MONEY).

§Examples
let amount = Amount::from_sat(sat)?;
assert_eq!(amount.to_sat(), sat);
Source§

impl Amount

Source

pub const ZERO: Self

The zero amount.

Source

pub const ONE_SAT: Self

Exactly one satoshi.

Source

pub const ONE_BTC: Self

Exactly one bitcoin.

Source

pub const FIFTY_BTC: Self

Exactly fifty bitcoin.

Source

pub const MAX_MONEY: Self = Self::MAX

The maximum value allowed as an amount. Useful for sanity checking.

Source

pub const SIZE: usize = 8

The number of bytes that an amount contributes to the size of a transaction.

Source

pub const fn from_sat_u32(satoshi: u32) -> Self

Constructs a new Amount with satoshi precision and the given number of satoshis.

Accepts an u32 which is guaranteed to be in range for the type, but which can only represent roughly 0 to 42.95 BTC.

Source

pub fn from_btc(btc: f64) -> Result<Self, ParseAmountError>

Converts from a value expressing a decimal number of bitcoin to an Amount.

§Errors

If the amount is too precise, negative, or greater than 21,000,000.

Please be aware of the risk of using floating-point numbers.

§Examples
let amount = Amount::from_btc(0.01)?;
assert_eq!(amount.to_sat(), 1_000_000);
Source

pub fn from_int_btc<T: Into<u16>>(whole_bitcoin: T) -> Self

Converts from a value expressing a whole number of bitcoin to an Amount.

Source

pub const fn from_btc_u16(whole_bitcoin: u16) -> Self

Converts from a value expressing a whole number of bitcoin to an Amount in const context.

Source

pub fn from_str_in( s: &str, denom: Denomination, ) -> Result<Self, ParseAmountError>

Parses a decimal string as a value in the given Denomination.

Note: This only parses the value string. If you want to parse a string containing the value with denomination, use FromStr.

§Errors

If the amount is too precise, negative, or greater than 21,000,000.

Source

pub fn from_str_with_denomination(s: &str) -> Result<Self, ParseError>

Parses amounts with denomination suffix as produced by Self::to_string_with_denomination or with fmt::Display.

If you want to parse only the amount without the denomination, use Self::from_str_in.

§Errors

If the amount is too big, too precise or negative.

§Examples
let amount = Amount::from_str_with_denomination("0.1 BTC")?;
assert_eq!(amount, Amount::from_sat(10_000_000)?);
Source

pub fn to_float_in(self, denom: Denomination) -> f64

Expresses this Amount as a floating-point value in the given Denomination.

Please be aware of the risk of using floating-point numbers.

§Examples
let amount = Amount::from_sat(100_000)?;
assert_eq!(amount.to_float_in(Denomination::Bitcoin), 0.001);
Source

pub fn to_btc(self) -> f64

Expresses this Amount as a floating-point value in Bitcoin.

Please be aware of the risk of using floating-point numbers.

§Examples
let amount = Amount::from_sat(100_000)?;
assert_eq!(amount.to_btc(), amount.to_float_in(Denomination::Bitcoin));
Source

pub fn from_float_in( value: f64, denom: Denomination, ) -> Result<Self, ParseAmountError>

Converts this Amount in floating-point notation in the given Denomination.

§Errors

If the amount is too big, too precise or negative.

Please be aware of the risk of using floating-point numbers.

Source

pub fn display_in(self, denomination: Denomination) -> Display

Constructs a new object that implements fmt::Display in the given Denomination.

This function is useful if you do not wish to allocate. See also Self::to_string_in.

§Examples
let amount = Amount::from_sat(10_000_000)?;
let mut output = String::new();
let _ = write!(&mut output, "{}", amount.display_in(Denomination::Bitcoin));
assert_eq!(output, "0.1");
Source

pub fn display_dynamic(self) -> Display

Constructs a new object that implements fmt::Display dynamically selecting Denomination.

This will use BTC for values greater than or equal to 1 BTC and satoshis otherwise. To avoid confusion the denomination is always shown.

Source

pub fn to_string_in(self, denom: Denomination) -> String

Returns a formatted string representing this Amount in the given Denomination.

Returned string does not include the denomination.

§Examples
let amount = Amount::from_sat(10_000_000)?;
assert_eq!(amount.to_string_in(Denomination::Bitcoin), "0.1");
Source

pub fn to_string_with_denomination(self, denom: Denomination) -> String

Returns a formatted string representing this Amount in the given Denomination, suffixed with the abbreviation for the denomination.

§Examples
let amount = Amount::from_sat(10_000_000)?;
assert_eq!(amount.to_string_with_denomination(Denomination::Bitcoin), "0.1 BTC");
Source

pub const fn checked_add(self, rhs: Self) -> Option<Self>

Checked addition.

Returns None if the sum is larger than Amount::MAX.

Source

pub const fn checked_sub(self, rhs: Self) -> Option<Self>

Checked subtraction.

Returns None if overflow occurred.

Source

pub const fn checked_mul(self, rhs: u64) -> Option<Self>

Checked multiplication.

Returns None if the product is larger than Amount::MAX.

Source

pub const fn checked_div(self, rhs: u64) -> Option<Self>

Checked integer division.

Be aware that integer division loses the remainder if no exact division can be made.

Returns None if overflow occurred.

Source

pub const fn checked_rem(self, rhs: u64) -> Option<Self>

Checked remainder.

Returns None if overflow occurred.

Source

pub fn to_signed(self) -> SignedAmount

Converts to a signed amount.

Source

pub fn signed_sub(self, rhs: Self) -> SignedAmount

Infallibly subtracts one Amount from another returning a SignedAmount.

Since SignedAmount::MIN is equivalent to -Amount::MAX subtraction of two signed amounts can never overflow a SignedAmount.

Source

pub const fn div_by_weight_floor(self, weight: Weight) -> NumOpResult<FeeRate>

Checked weight floor division.

Be aware that integer division loses the remainder if no exact division can be made. See also Self::div_by_weight_ceil.

Source

pub const fn div_by_weight_ceil(self, weight: Weight) -> NumOpResult<FeeRate>

Checked weight ceiling division.

Be aware that integer division loses the remainder if no exact division can be made. This method rounds up ensuring the transaction fee rate is sufficient. See also Self::div_by_weight_floor.

§Examples
let amount = Amount::from_sat(10)?;
let weight = Weight::from_wu(300);
let fee_rate = amount.div_by_weight_ceil(weight).expect("valid fee rate");
assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(34));
Source

pub const fn div_by_fee_rate_floor( self, fee_rate: FeeRate, ) -> NumOpResult<Weight>

Checked fee rate floor division.

Computes the maximum weight that would result in a fee less than or equal to this amount at the given fee_rate. Uses floor division to ensure the resulting weight doesn’t cause the fee to exceed the amount.

Source

pub const fn div_by_fee_rate_ceil( self, fee_rate: FeeRate, ) -> NumOpResult<Weight>

Checked fee rate ceiling division.

Computes the minimum weight that would result in a fee greater than or equal to this amount at the given fee_rate. Uses ceiling division to ensure the resulting weight is sufficient.

Trait Implementations§

Source§

impl<'a> Add<&'a Amount> for &Amount

Source§

type Output = <Amount as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Amount) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Amount> for Amount

Source§

type Output = <Amount as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Amount) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&NumOpResult<Amount>> for Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Amount> for &Amount

Source§

type Output = <Amount as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Amount) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<Amount>> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Amount) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Amount> for NumOpResult<Amount>

Source§

fn add_assign(&mut self, rhs: Amount)

Performs the += operation. Read more
Source§

impl<'a> Arbitrary<'a> for Amount

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Binary for Amount

Source§

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

Formats the value using the given formatter. 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

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

impl Decodable for Amount

Available on crate feature encoding only.
Source§

type Decoder = AmountDecoder

Associated decoder for the type.
Source§

fn decoder() -> Self::Decoder

Constructs a “default decoder” for the type.
Source§

impl Default for Amount

Source§

fn default() -> Self

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

impl Display for Amount

Source§

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

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

impl<'a> Div<&'a Amount> for &Amount

Source§

type Output = <Amount as Div>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Amount) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Amount> for Amount

Source§

type Output = <Amount as Div>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Amount) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a FeeRate> for &Amount

Source§

type Output = <Amount as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&FeeRate> for Amount

Source§

type Output = <Amount as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NonZero<u64>> for &Amount

Source§

type Output = <Amount as Div<NonZero<u64>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZeroU64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NonZero<u64>> for Amount

Source§

type Output = <Amount as Div<NonZero<u64>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZeroU64) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<FeeRate>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<FeeRate>> for Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<Weight>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<Weight>> for Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a Weight> for &Amount

Source§

type Output = <Amount as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Weight> for Amount

Source§

type Output = <Amount as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a u64> for &Amount

Source§

type Output = <Amount as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&u64> for Amount

Source§

type Output = <Amount as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Amount> for &Amount

Source§

type Output = <Amount as Div>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Amount) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<FeeRate> for &Amount

Source§

type Output = <Amount as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<FeeRate> for Amount

Source§

type Output = NumOpResult<Weight>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NonZero<u64>> for &Amount

Source§

type Output = <Amount as Div<NonZero<u64>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZeroU64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NonZero<u64>> for Amount

Source§

type Output = Amount

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZeroU64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for Amount

Source§

type Output = NumOpResult<Weight>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for Amount

Source§

type Output = NumOpResult<FeeRate>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Weight> for &Amount

Source§

type Output = <Amount as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Weight> for Amount

Source§

type Output = NumOpResult<FeeRate>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u64> for &Amount

Source§

type Output = <Amount as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u64> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Amount

Source§

type Output = NumOpResult<u64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Amount) -> Self::Output

Performs the / operation. Read more
Source§

impl Encodable for Amount

Available on crate feature encoding only.
Source§

type Encoder<'e> = AmountEncoder<'e>

The encoder associated with this type. Conceptually, the encoder is like an iterator which yields byte slices.
Source§

fn encoder(&self) -> Self::Encoder<'_>

Constructs a “default encoder” for the type.
Source§

impl From<&Amount> for NumOpResult<Amount>

Source§

fn from(a: &Amount) -> Self

Converts to this type from the input type.
Source§

impl From<Amount> for NumOpResult<Amount>

Source§

fn from(a: Amount) -> Self

Converts to this type from the input type.
Source§

impl From<Amount> for SignedAmount

Source§

fn from(value: Amount) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Amount

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string slice where the slice includes a denomination.

If the returned value would be zero or negative zero, then no denomination is required.

Source§

type Err = ParseError

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

impl Hash for Amount

Source§

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

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 LowerHex for Amount

Source§

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

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

impl<'a> Mul<&'a Amount> for &u64

Source§

type Output = <u64 as Mul<Amount>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Amount) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Amount> for u64

Source§

type Output = <u64 as Mul<Amount>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Amount) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a u64> for &Amount

Source§

type Output = <Amount as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&u64> for Amount

Source§

type Output = <Amount as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Amount> for &u64

Source§

type Output = <u64 as Mul<Amount>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Amount) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Amount> for u64

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Amount) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for &Amount

Source§

type Output = <Amount as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Octal for Amount

Source§

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

Formats the value using the given formatter. 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 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 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<'a> Rem<&'a u64> for &Amount

Source§

type Output = <Amount as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&u64> for Amount

Source§

type Output = <Amount as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<u64> for &Amount

Source§

type Output = <Amount as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<u64> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the % operator.
Source§

fn rem(self, modulus: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Sub<&'a Amount> for &Amount

Source§

type Output = <Amount as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Amount) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&Amount> for Amount

Source§

type Output = <Amount as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Amount) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&NumOpResult<Amount>> for Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Amount> for &Amount

Source§

type Output = <Amount as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Amount) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<Amount>> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Amount) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Amount> for NumOpResult<Amount>

Source§

fn sub_assign(&mut self, rhs: Amount)

Performs the -= operation. Read more
Source§

impl TryFrom<SignedAmount> for Amount

Source§

type Error = OutOfRangeError

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

fn try_from(value: SignedAmount) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpperHex for Amount

Source§

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

Formats the value using the given formatter. Read more
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.