pub struct Rate(pub U128);Expand description
Small decimal values, precise to 18 digits
Tuple Fields§
§0: U128Implementations§
Source§impl 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
Trait Implementations§
Source§impl From<CollateralExchangeRate> for Rate
impl From<CollateralExchangeRate> for Rate
Source§fn from(exchange_rate: CollateralExchangeRate) -> Self
fn from(exchange_rate: CollateralExchangeRate) -> Self
Converts to this type from the input type.
Source§impl Ord for Rate
impl Ord for Rate
Source§impl PartialOrd for Rate
impl PartialOrd for Rate
Source§impl TryDiv<Rate> for Rate
impl TryDiv<Rate> for Rate
Source§fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
Divide
Source§impl TryMul<Rate> for Rate
impl TryMul<Rate> for Rate
Source§fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
Multiply
impl Copy for Rate
impl Eq for Rate
impl StructuralPartialEq for Rate
Auto Trait Implementations§
impl Freeze for Rate
impl RefUnwindSafe for Rate
impl Send for Rate
impl Sync for Rate
impl Unpin for Rate
impl UnwindSafe for Rate
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more