pub struct Wad(pub Number);Expand description
An 18-decimal fixed-point value (1e18 = 100%), backed by U256.
When the serde feature is enabled, serializes transparently as Number
(which serializes to a decimal string for JSON compatibility).
Tuple Fields§
§0: NumberImplementations§
Source§impl Wad
impl Wad
pub const ZERO: Self
pub const ONE: Self
pub fn is_zero(&self) -> bool
pub fn is_one(&self) -> bool
Sourcepub fn as_u128_trunc(self) -> u128
pub fn as_u128_trunc(self) -> u128
Returns the lower 128 bits (truncation) of this WAD value.
Sourcepub fn apply_floored(self, amount: Number) -> Number
pub fn apply_floored(self, amount: Number) -> Number
Applies this WAD-scaled fraction to an unscaled Number, floored.
Trait Implementations§
Source§impl BorshDeserialize for Wad
impl BorshDeserialize for Wad
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 Wad
impl BorshSchema for Wad
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§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
Source§impl<'de> Deserialize<'de> for Wad
impl<'de> Deserialize<'de> for Wad
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 Wad
impl JsonSchema for Wad
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. 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 Wad
impl Ord for Wad
Source§impl PartialOrd for Wad
impl PartialOrd for Wad
impl Copy for Wad
impl Eq for Wad
impl StructuralPartialEq for Wad
Auto Trait Implementations§
impl Freeze for Wad
impl RefUnwindSafe for Wad
impl Send for Wad
impl Sync for Wad
impl Unpin for Wad
impl UnwindSafe for Wad
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