Struct bitcoin::util::amount::Amount [−][src]
pub struct Amount(_);
Expand description
Amount
The Amount type can be used to express Bitcoin amounts that supports arithmetic and conversion to various denominations.
Warning!
This type implements several arithmetic operations from core::ops.
To prevent errors due to overflow or underflow 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 overflow or underflow occurs. Also note that
since the internal representation of amounts is unsigned, subtracting below
zero is considered an underflow and will cause a panic if you’re not using
the checked arithmetic methods.
Implementations
Create an Amount with satoshi precision and the given number of satoshis.
Convert from a value expressing bitcoins to an Amount.
Parse a decimal string as a value in the given denomination.
Note: This only parses the value string. If you want to parse a value with denomination, use FromStr.
Parses amounts with denomination suffix like they are produced with 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.
Express this Amount as a floating-point value in the given denomination.
Please be aware of the risk of using floating-point numbers.
Express this Amount as a floating-point value in Bitcoin.
Equivalent to to_float_in(Denomination::Bitcoin)
.
Please be aware of the risk of using floating-point numbers.
Convert this Amount in floating-point notation with a given denomination. Can return error if the amount is too big, too precise or negative.
Please be aware of the risk of using floating-point numbers.
Format the value of this Amount in the given denomination.
Does not include the denomination.
Get a string number of this Amount in the given denomination.
Does not include the denomination.
Get a formatted string of this Amount in the given denomination, suffixed with the abbreviation for the denomination.
Checked addition. Returns None if overflow occurred.
Checked subtraction. Returns None if overflow occurred.
Checked multiplication. Returns None if overflow occurred.
Checked integer division. Be aware that integer division loses the remainder if no exact division can be made. Returns None if overflow occurred.
Checked remainder. Returns None if overflow occurred.
Convert to a signed amount.
Trait Implementations
Performs the +=
operation. Read more
Performs the /=
operation. Read more
Performs the *=
operation. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Performs the %=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Amount
impl UnwindSafe for Amount
Blanket Implementations
Mutably borrows from an owned value. Read more