Struct fadroma::math::Decimal256
source · [−]pub struct Decimal256(pub U256);
Expand description
A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0 The greatest possible value that can be represented is 115792089237316195423570985008687907853269984665640564039457.584007913129639935 (which is (2^128 - 1) / 10^18)
Tuple Fields
0: U256
Implementations
sourceimpl Decimal256
impl Decimal256
pub const DECIMAL_FRACTIONAL: U256 = U256([1_000_000_000_000_000_000u64, 0, 0, 0])
sourcepub fn from_ratio<A: Into<U256>, B: Into<U256>>(
nominator: A,
denominator: B
) -> StdResult<Self>
pub fn from_ratio<A: Into<U256>, B: Into<U256>>(
nominator: A,
denominator: B
) -> StdResult<Self>
Returns the ratio (nominator / denominator) as a Decimal256
pub fn from_uint256(value: impl Into<Uint256>) -> StdResult<Self>
pub fn round(self) -> Uint256
pub const MAX: Self = Self(primitive_types::U256::MAX)
pub const fn zero() -> Self
pub fn is_zero(&self) -> bool
pub fn checked_div(self, rhs: Self) -> StdResult<Self>
pub fn checked_mul(self, rhs: Self) -> StdResult<Self>
pub fn checked_sub(self, rhs: Self) -> StdResult<Self>
pub fn checked_add(self, rhs: Self) -> StdResult<Self>
Trait Implementations
sourceimpl Add<Decimal256> for Decimal256
impl Add<Decimal256> for Decimal256
sourceimpl Canonize for Decimal256
impl Canonize for Decimal256
sourceimpl Clone for Decimal256
impl Clone for Decimal256
sourcefn clone(&self) -> Decimal256
fn clone(&self) -> Decimal256
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Decimal256
impl Debug for Decimal256
sourceimpl Default for Decimal256
impl Default for Decimal256
sourcefn default() -> Decimal256
fn default() -> Decimal256
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for Decimal256
impl<'de> Deserialize<'de> for Decimal256
Deserializes as a base64 string
sourcefn deserialize<D>(deserializer: D) -> Result<Decimal256, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Decimal256, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Decimal256
impl Display for Decimal256
sourceimpl Div<Decimal256> for Decimal256
impl Div<Decimal256> for Decimal256
sourceimpl From<Decimal256> for Uint256
impl From<Decimal256> for Uint256
sourcefn from(value: Decimal256) -> Self
fn from(value: Decimal256) -> Self
Converts to this type from the input type.
sourceimpl FromStr for Decimal256
impl FromStr for Decimal256
sourceimpl Humanize for Decimal256
impl Humanize for Decimal256
sourceimpl JsonSchema for Decimal256
impl JsonSchema for Decimal256
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn 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 more
sourceimpl Mul<Decimal256> for Decimal256
impl Mul<Decimal256> for Decimal256
sourceimpl Ord for Decimal256
impl Ord for Decimal256
sourceimpl PartialEq<Decimal256> for Decimal256
impl PartialEq<Decimal256> for Decimal256
sourcefn eq(&self, other: &Decimal256) -> bool
fn eq(&self, other: &Decimal256) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Decimal256) -> bool
fn ne(&self, other: &Decimal256) -> bool
This method tests for !=
.
sourceimpl PartialOrd<Decimal256> for Decimal256
impl PartialOrd<Decimal256> for Decimal256
sourcefn partial_cmp(&self, other: &Decimal256) -> Option<Ordering>
fn partial_cmp(&self, other: &Decimal256) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Decimal256
impl Serialize for Decimal256
Serializes as a decimal string
sourceimpl Sub<Decimal256> for Decimal256
impl Sub<Decimal256> for Decimal256
sourceimpl TryFrom<Decimal> for Decimal256
impl TryFrom<Decimal> for Decimal256
sourceimpl TryFrom<Uint256> for Decimal256
impl TryFrom<Uint256> for Decimal256
impl Copy for Decimal256
impl Eq for Decimal256
impl StructuralEq for Decimal256
impl StructuralPartialEq for Decimal256
Auto Trait Implementations
impl RefUnwindSafe for Decimal256
impl Send for Decimal256
impl Sync for Decimal256
impl Unpin for Decimal256
impl UnwindSafe for Decimal256
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more