pub struct Rate(pub U128);Expand description
Small decimal values, precise to 18 digits
Tuple Fields
0: U128Implementations
sourceimpl Rate
impl Rate
sourcepub fn from_percent(percent: u8) -> Self
pub fn from_percent(percent: u8) -> Self
Create scaled decimal from percent value
sourcepub fn to_scaled_val(&self) -> u128
pub fn to_scaled_val(&self) -> u128
Return raw scaled value
sourcepub fn from_scaled_val(scaled_val: u64) -> Self
pub fn from_scaled_val(scaled_val: u64) -> Self
Create decimal from scaled value
sourcepub fn from_scaled_val_big(scaled_val_big: u128) -> Self
pub fn from_scaled_val_big(scaled_val_big: u128) -> Self
Create decimal from double scaled???
sourcepub fn try_round_u64(&self) -> Result<u64, ProgramError>
pub fn try_round_u64(&self) -> Result<u64, ProgramError>
Round scaled decimal to u64
sourcepub fn try_floor_u64(&self) -> Result<u64, ProgramError>
pub fn try_floor_u64(&self) -> Result<u64, ProgramError>
Floor scaled decimal to u64
Trait Implementations
sourceimpl From<CollateralExchangeRate> for Rate
impl From<CollateralExchangeRate> for Rate
sourcefn from(exchange_rate: CollateralExchangeRate) -> Self
fn from(exchange_rate: CollateralExchangeRate) -> Self
Converts to this type from the input type.
sourceimpl Ord for Rate
impl Ord for Rate
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) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Rate> for Rate
impl PartialOrd<Rate> for Rate
sourcefn partial_cmp(&self, other: &Rate) -> Option<Ordering>
fn partial_cmp(&self, other: &Rate) -> Option<Ordering>
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 moresourceimpl TryDiv<Rate> for Decimal
impl TryDiv<Rate> for Decimal
sourcefn try_div(self, rhs: Rate) -> Result<Self, ProgramError>
fn try_div(self, rhs: Rate) -> Result<Self, ProgramError>
Divide
sourceimpl TryDiv<Rate> for Rate
impl TryDiv<Rate> for Rate
sourcefn try_div(self, rhs: Self) -> Result<Self, ProgramError>
fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
Divide
sourceimpl TryMul<Rate> for Decimal
impl TryMul<Rate> for Decimal
sourcefn try_mul(self, rhs: Rate) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Rate) -> Result<Self, ProgramError>
Multiply
sourceimpl TryMul<Rate> for Rate
impl TryMul<Rate> for Rate
sourcefn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
Multiply
sourceimpl TryMul<u64> for Rate
impl TryMul<u64> for Rate
sourcefn try_mul(self, rhs: u64) -> Result<Self, ProgramError>
fn try_mul(self, rhs: u64) -> Result<Self, ProgramError>
Multiply
impl Copy for Rate
impl Eq for Rate
impl StructuralEq for Rate
impl StructuralPartialEq for Rate
Auto Trait Implementations
impl RefUnwindSafe for Rate
impl Send for Rate
impl Sync for Rate
impl Unpin for Rate
impl UnwindSafe for Rate
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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