pub struct Pips(/* private fields */);Expand description
1 pip == 1/100th of bip == 0.0001%
Implementations§
Source§impl Pips
impl Pips
pub const ZERO: Self
pub const ONE_PIP: Self
pub const ONE_BIP: Self
pub const ONE_PERCENT: Self
pub const MAX: Self
pub const fn from_pips(pips: u32) -> Option<Self>
pub const fn from_bips(bips: u32) -> Option<Self>
pub const fn from_percent(percent: u32) -> Option<Self>
pub const fn as_pips(self) -> u32
pub const fn as_bips(self) -> u32
pub const fn as_percent(self) -> u32
pub const fn is_zero(&self) -> bool
pub fn as_f64(self) -> f64
pub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: u32) -> Option<Self>
pub const fn checked_div(self, rhs: u32) -> Option<Self>
pub const fn invert(self) -> Self
pub fn fee(self, amount: u128) -> u128
pub fn fee_ceil(self, amount: u128) -> u128
Trait Implementations§
Source§impl BorshDeserialize for Pips
Available on crate feature borsh only.
impl BorshDeserialize for Pips
Available on crate feature
borsh only.fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self>
§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.
§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 BorshSchema for Pips
impl BorshSchema for Pips
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
Source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition>, )
Recursively, using DFS, add type definitions required for this type.
Type definition partially explains how to serialize/deserialize a type.
Source§impl<'de> Deserialize<'de> for Pips
impl<'de> Deserialize<'de> for Pips
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 JsonSchema for Pips
impl JsonSchema for Pips
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§impl Ord for Pips
impl Ord for Pips
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 Pips
impl PartialOrd for Pips
impl Copy for Pips
impl Eq for Pips
impl StructuralPartialEq for Pips
Auto Trait Implementations§
impl Freeze for Pips
impl RefUnwindSafe for Pips
impl Send for Pips
impl Sync for Pips
impl Unpin for Pips
impl UnsafeUnpin for Pips
impl UnwindSafe for Pips
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.