pub struct Ppm(/* private fields */);Expand description
A “parts per million” value for proportional fee rates.
Internally stores an i32 in the range [0, 1_000_000].
1_000_000 ppm = 100%, so 5000 ppm = 0.5%.
Implementations§
Source§impl Ppm
impl Ppm
Sourcepub fn try_from_decimal(rate: Decimal) -> Result<Self, Error>
pub fn try_from_decimal(rate: Decimal) -> Result<Self, Error>
Sourcepub fn try_from_percent(pct: Decimal) -> Result<Self, Error>
pub fn try_from_percent(pct: Decimal) -> Result<Self, Error>
Sourcepub const fn to_decimal(self) -> Decimal
pub const fn to_decimal(self) -> Decimal
Returns the ppm value as a Decimal rate (ppm / 1_000_000).
For example, 5000 ppm becomes 0.005 (0.5%).
Sourcepub const fn to_percent(self) -> Decimal
pub const fn to_percent(self) -> Decimal
Returns the ppm value as a Decimal percentage (ppm / 10_000).
For example, 5000 ppm becomes 0.5 (0.5%).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ppm
impl<'de> Deserialize<'de> for Ppm
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 Ord for Ppm
impl Ord for Ppm
1.21.0 (const: unstable) · 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 PartialOrd for Ppm
impl PartialOrd for Ppm
impl Copy for Ppm
impl Eq for Ppm
impl StructuralPartialEq for Ppm
Auto Trait Implementations§
impl Freeze for Ppm
impl RefUnwindSafe for Ppm
impl Send for Ppm
impl Sync for Ppm
impl Unpin for Ppm
impl UnsafeUnpin for Ppm
impl UnwindSafe for Ppm
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