Struct walletd_bitcoin::BitcoinAmount
source · pub struct BitcoinAmount {
pub satoshi: u64,
}
Expand description
Contains a field representing the amount of satoshis in the amount. Has functions to convert to and from the main unit (BTC) and the smallest unit (satoshi).
Fields§
§satoshi: u64
The number of satoshis (the smallest unit of the bitcoin currency) in the amount.
There are 100 million satoshis per bitcoin (BTC).
Implementations§
source§impl BitcoinAmount
impl BitcoinAmount
sourcepub fn from_btc(btc_amount: f64) -> Self
pub fn from_btc(btc_amount: f64) -> Self
Returns a BitcoinAmount struct from a decimal value representing the amount in BTC.
sourcepub fn from_satoshi(satoshi_amount: u64) -> Self
pub fn from_satoshi(satoshi_amount: u64) -> Self
Returns a BitcoinAmount struct from an integer value representing the amount in satoshis.
Trait Implementations§
source§impl Add<BitcoinAmount> for BitcoinAmount
impl Add<BitcoinAmount> for BitcoinAmount
source§impl Clone for BitcoinAmount
impl Clone for BitcoinAmount
source§fn clone(&self) -> BitcoinAmount
fn clone(&self) -> BitcoinAmount
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 CryptoAmount for BitcoinAmount
impl CryptoAmount for BitcoinAmount
source§fn from_main_unit_decimal_value(value: f64) -> Self
fn from_main_unit_decimal_value(value: f64) -> Self
In the units of main “big” unit (a floating point number, not an integer
subdivision) using decimal value, for bitcoin BTC, ethereum ETH, etc.
The CryptoAmount is a wrapper around a floating point number and the default integer value stored is in the smallest unit of the coin.
For example this would be satoshi for bitcoin, wei for ethereum, etc.
The decimal value is the floating point number representation in the main unit of the coin, for example BTC, ETH, etc.
source§fn from_smallest_unit_integer_value(value: u64) -> Self
fn from_smallest_unit_integer_value(value: u64) -> Self
Creates a new CryptoAmount from the smallest unit of the coin, for example satoshi for bitcoin, wei for ethereum, etc.
source§fn to_main_unit_decimal_value(&self) -> f64
fn to_main_unit_decimal_value(&self) -> f64
Returns the decimal value of the CryptoAmount, this is the floating point number representation in the main unit of the coin, for example BTC, ETH, etc.
source§fn to_smallest_unit_integer_value(&self) -> u64
fn to_smallest_unit_integer_value(&self) -> u64
Returns the integer value of the CryptoAmount, this is the integer representation in the smallest unit of the coin, for example satoshi for bitcoin, wei for ethereum, etc.
source§impl Default for BitcoinAmount
impl Default for BitcoinAmount
source§fn default() -> BitcoinAmount
fn default() -> BitcoinAmount
Returns the “default value” for a type. Read more
source§impl Mul<f64> for BitcoinAmount
impl Mul<f64> for BitcoinAmount
source§impl Ord for BitcoinAmount
impl Ord for BitcoinAmount
source§fn cmp(&self, other: &BitcoinAmount) -> Ordering
fn cmp(&self, other: &BitcoinAmount) -> 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<BitcoinAmount> for BitcoinAmount
impl PartialEq<BitcoinAmount> for BitcoinAmount
source§fn eq(&self, other: &BitcoinAmount) -> bool
fn eq(&self, other: &BitcoinAmount) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<BitcoinAmount> for BitcoinAmount
impl PartialOrd<BitcoinAmount> for BitcoinAmount
source§fn partial_cmp(&self, other: &BitcoinAmount) -> Option<Ordering>
fn partial_cmp(&self, other: &BitcoinAmount) -> 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 Sub<BitcoinAmount> for BitcoinAmount
impl Sub<BitcoinAmount> for BitcoinAmount
impl Copy for BitcoinAmount
impl Eq for BitcoinAmount
impl StructuralEq for BitcoinAmount
impl StructuralPartialEq for BitcoinAmount
Auto Trait Implementations§
impl RefUnwindSafe for BitcoinAmount
impl Send for BitcoinAmount
impl Sync for BitcoinAmount
impl Unpin for BitcoinAmount
impl UnwindSafe for BitcoinAmount
Blanket Implementations§
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> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.