pub struct Balance(/* private fields */);
Expand description
Represents balance of some coin or token.
Implementations§
Source§impl Balance
impl Balance
Sourcepub fn new<T: Into<U256>>(value: T, balance_type: BalanceType) -> Self
pub fn new<T: Into<U256>>(value: T, balance_type: BalanceType) -> Self
Creates a new balance given the value and type
Sourcepub fn new_from_str(value: &str, balance_type: BalanceType) -> Self
pub fn new_from_str(value: &str, balance_type: BalanceType) -> Self
Creates new balance of the given type from the base 10 integer string
Sourcepub fn zero(balance_type: BalanceType) -> Self
pub fn zero(balance_type: BalanceType) -> Self
Creates zero balance of the given type
Sourcepub fn balance_type(&self) -> BalanceType
pub fn balance_type(&self) -> BalanceType
Retrieves the type (symbol) of the balance
Sourcepub fn of_same(&self, value: &str) -> Self
pub fn of_same(&self, value: &str) -> Self
Creates balance of the given value with the same symbol
pub fn amount(&self) -> U256
pub fn is_zero(&self) -> bool
pub fn amount_base_units(&self) -> String
pub fn to_formatted_string(&self) -> String
pub fn to_value_string(&self) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Balance
impl<'de> Deserialize<'de> for Balance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Into<U256>> From<(T, BalanceType)> for Balance
impl<T: Into<U256>> From<(T, BalanceType)> for Balance
Source§fn from(value: (T, BalanceType)) -> Self
fn from(value: (T, BalanceType)) -> Self
Converts to this type from the input type.
Source§impl PartialOrd for Balance
impl PartialOrd for Balance
Source§impl UnitaryFloatOps for Balance
impl UnitaryFloatOps for Balance
impl Copy for Balance
impl Eq for Balance
impl StructuralPartialEq for Balance
Auto Trait Implementations§
impl Freeze for Balance
impl RefUnwindSafe for Balance
impl Send for Balance
impl Sync for Balance
impl Unpin for Balance
impl UnwindSafe for Balance
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