pub struct BasisPoints(/* private fields */);Expand description
A validated basis-points value in the inclusive range 0..=10_000.
Implementations§
Source§impl BasisPoints
impl BasisPoints
Sourcepub fn new(bps: u16) -> Result<Self, BasisPointsError>
pub fn new(bps: u16) -> Result<Self, BasisPointsError>
Creates a new BasisPoints after validating the input range.
Returns BasisPointsError::InvalidBasisPoints if bps > 10_000.
Sourcepub fn checked_add(self, rhs: Self) -> Option<Self>
pub fn checked_add(self, rhs: Self) -> Option<Self>
Checked addition. Returns None if the result exceeds 10_000.
Sourcepub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
Checked subtraction. Returns None if underflow occurs.
Sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Checked multiplication. Returns None if the result exceeds 10_000.
Sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Checked division. Returns None on division-by-zero.
Trait Implementations§
Source§impl BorshDeserialize for BasisPoints
impl BorshDeserialize for BasisPoints
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for BasisPoints
impl BorshSerialize for BasisPoints
Source§impl Clone for BasisPoints
impl Clone for BasisPoints
Source§fn clone(&self) -> BasisPoints
fn clone(&self) -> BasisPoints
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for BasisPoints
Source§impl Debug for BasisPoints
impl Debug for BasisPoints
impl Eq for BasisPoints
Source§impl From<BasisPoints> for Decimal
Available on crate feature decimal only.
impl From<BasisPoints> for Decimal
Available on crate feature
decimal only.Source§fn from(bps: BasisPoints) -> Self
fn from(bps: BasisPoints) -> Self
Converts basis points to a proportional rate in 0..=1 (divide by 10_000).
Source§impl From<BasisPoints> for u128
impl From<BasisPoints> for u128
Source§fn from(bps: BasisPoints) -> Self
fn from(bps: BasisPoints) -> Self
Converts to this type from the input type.
Source§impl From<BasisPoints> for u16
impl From<BasisPoints> for u16
Source§fn from(bps: BasisPoints) -> Self
fn from(bps: BasisPoints) -> Self
Converts to this type from the input type.
Source§impl From<BasisPoints> for u32
impl From<BasisPoints> for u32
Source§fn from(bps: BasisPoints) -> Self
fn from(bps: BasisPoints) -> Self
Converts to this type from the input type.
Source§impl From<BasisPoints> for u64
impl From<BasisPoints> for u64
Source§fn from(bps: BasisPoints) -> Self
fn from(bps: BasisPoints) -> Self
Converts to this type from the input type.
Source§impl IdlBuild for BasisPoints
impl IdlBuild for BasisPoints
Source§fn create_type() -> Option<IdlTypeDef>
fn create_type() -> Option<IdlTypeDef>
Create an IDL type definition for the type. Read more
Source§fn insert_types(types: &mut BTreeMap<String, IdlTypeDef>)
fn insert_types(types: &mut BTreeMap<String, IdlTypeDef>)
Insert all types that are included in the current type definition to the given map.
Source§fn get_full_path() -> String
fn get_full_path() -> String
Get the full module path of the type. Read more
Source§impl PartialEq for BasisPoints
impl PartialEq for BasisPoints
Source§fn eq(&self, other: &BasisPoints) -> bool
fn eq(&self, other: &BasisPoints) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Pod for BasisPoints
Source§impl Space for BasisPoints
impl Space for BasisPoints
const INIT_SPACE: usize
impl StructuralPartialEq for BasisPoints
Source§impl TryFrom<Decimal> for BasisPoints
Available on crate feature decimal only.
impl TryFrom<Decimal> for BasisPoints
Available on crate feature
decimal only.Auto Trait Implementations§
impl Freeze for BasisPoints
impl RefUnwindSafe for BasisPoints
impl Send for BasisPoints
impl Sync for BasisPoints
impl Unpin for BasisPoints
impl UnsafeUnpin for BasisPoints
impl UnwindSafe for BasisPoints
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.