Struct monero::util::amount::Amount

source ·
pub struct Amount(_);
Expand description

Represent an unsigned quantity of Monero, internally as piconero.

The Amount type can be used to express Monero amounts that supports arithmetic and conversion to various denominations.

Implementations§

The zero amount.

Exactly one piconero.

Exactly one monero.

Create an Amount with piconero precision and the given number of piconero.

Get the number of piconeros in this Amount.

The maximum value of an Amount.

The minimum value of an Amount.

Convert from a value expressing moneros 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 to_string_with_denomination or with fmt::Display. If you want to parse only the amount without the denomination, use 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 Monero.

Equivalent to to_float_in(Denomination::Monero).

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§

The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
Performs the /= operation. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
Performs the *= operation. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The resulting type after applying the % operator.
Performs the % operation. Read more
Performs the %= operation. Read more
Serialize with Serializer the amount as piconero.
Deserialize with Deserializer an amount in piconero.
Serialize with Serializer the amount as monero.
Deserialize with Deserializer an amount in monero.
Return the type prefix (i or u) used to sign or not the amount.
Serialize with Serializer an optional amount as piconero.
Serialize with Serializer an optional amount as monero.
Return the type prefix (i or u) used to sign or not the amount.
Serialize with Serializer a slice of amounts as a slice of piconeros.
Serialize with Serializer a slice of amounts as a slice of moneros.
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.