pub struct Bps(/* private fields */);Expand description
A basis-points value validated to the range [0, 10000].
10000 bps = 100% = 1.0 as a fraction.
Implementations§
Source§impl Bps
impl Bps
Sourcepub fn new(value: Decimal) -> Result<Self, BpsError>
pub fn new(value: Decimal) -> Result<Self, BpsError>
Create a new basis-points value, validating that the value is in [0, 10000].
Sourcepub fn from_trusted(value: u32) -> Self
pub fn from_trusted(value: u32) -> Self
Sourcepub fn as_fraction(&self) -> Decimal
pub fn as_fraction(&self) -> Decimal
Convert to a Fraction in [0.0, 1.0].
100 bps → 0.01, 10000 bps → 1.0.
Sourcepub fn to_fraction(&self) -> Fraction
pub fn to_fraction(&self) -> Fraction
Convert to a validated Fraction value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bps
impl<'de> Deserialize<'de> for Bps
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 Bps
impl Ord for Bps
Source§impl PartialOrd for Bps
impl PartialOrd for Bps
impl Copy for Bps
impl Eq for Bps
impl StructuralPartialEq for Bps
Auto Trait Implementations§
impl Freeze for Bps
impl RefUnwindSafe for Bps
impl Send for Bps
impl Sync for Bps
impl Unpin for Bps
impl UnsafeUnpin for Bps
impl UnwindSafe for Bps
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