pub struct Decimal(_);
Expand description
Decimal type which follows Cosmos sdk.Dec
conventions.
Implementations
sourceimpl Decimal
impl Decimal
sourcepub fn new(integral_digits: i64, fractional_digits: u64) -> Result<Self>
pub fn new(integral_digits: i64, fractional_digits: u64) -> Result<Self>
Create a new Decimal
with the given whole number and decimal
parts. The decimal part assumes 18 digits of precision e.g. a
decimal with (1, 1)
is 1.000000000000000001
.
18 digits required by the Cosmos SDK. See: See: https://github.com/cosmos/cosmos-sdk/blob/26d6e49/types/decimal.go#L23
sourcepub fn to_amino_bytes(self) -> Vec<u8>
pub fn to_amino_bytes(self) -> Vec<u8>
Serialize this Decimal
as Amino-encoded bytes
Trait Implementations
sourceimpl Ord for Decimal
impl Ord for Decimal
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
sourcefn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl Copy for Decimal
impl Eq for Decimal
impl StructuralEq for Decimal
impl StructuralPartialEq for Decimal
Auto Trait Implementations
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnwindSafe for Decimal
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more