Trait levana_perpswap_cosmos::number::UnsignedDecimal

source ·
pub trait UnsignedDecimal: Display + Debug + Serialize + DeserializeOwned + Copy + Ord + FromStr + Default {
Show 13 methods // Required methods fn into_decimal256(self) -> Decimal256; fn from_decimal256(src: Decimal256) -> Self; // Provided methods fn is_zero(&self) -> bool { ... } fn checked_add(self, rhs: Self) -> Result<Self, OverflowError> { ... } fn checked_add_signed(self, rhs: Signed<Self>) -> Result<Self> { ... } fn checked_sub(self, rhs: Self) -> Result<Self, OverflowError> { ... } fn try_from_number(_: Signed<Decimal256>) -> Result<Self> { ... } fn into_number(self) -> Signed<Decimal256> { ... } fn into_signed(self) -> Signed<Self> { ... } fn zero() -> Self { ... } fn two() -> Self { ... } fn diff(self, rhs: Self) -> Self { ... } fn approx_eq(self, rhs: Self) -> bool { ... }
}
Expand description

Generalizes any newtype wrapper around a Decimal256.

Required Methods§

source

fn into_decimal256(self) -> Decimal256

Convert into the underlying Decimal256.

source

fn from_decimal256(src: Decimal256) -> Self

Convert from a Decimal256.

Provided Methods§

source

fn is_zero(&self) -> bool

Check if the underlying value is 0.

source

fn checked_add(self, rhs: Self) -> Result<Self, OverflowError>

Add two values together

source

fn checked_add_signed(self, rhs: Signed<Self>) -> Result<Self>

Try to add a signed value to this, erroring if it results in a negative result.

source

fn checked_sub(self, rhs: Self) -> Result<Self, OverflowError>

Subtract two values

source

fn try_from_number(_: Signed<Decimal256>) -> Result<Self>

Try to convert from a general purpose Number

source

fn into_number(self) -> Signed<Decimal256>

convert into a general purpose Number

source

fn into_signed(self) -> Signed<Self>

Convert into a positive Signed value.

source

fn zero() -> Self

The value 0

source

fn two() -> Self

The value 2

source

fn diff(self, rhs: Self) -> Self

Difference between two values

source

fn approx_eq(self, rhs: Self) -> bool

Is the delta between these less than the epsilon value?

Epsilon is 10^-7

Object Safety§

This trait is not object safe.

Implementors§