Struct FixedU128

Source
pub struct FixedU128(/* private fields */);
Expand description

Re-export top-level arithmetic stuff. A fixed point number representation in the range.

Fixed Point 128 bits unsigned, range = [0.000000000000000000, 340282366920938463463.374607431768211455]

Implementations§

Source§

impl FixedU128

Source

pub const fn from_inner(inner: u128) -> FixedU128

const version of FixedPointNumber::from_inner.

Source

pub fn from_fraction(x: f64) -> FixedU128

Source

pub fn to_fraction(self) -> f64

Trait Implementations§

Source§

impl Add for FixedU128

Source§

type Output = FixedU128

The resulting type after applying the + operator.
Source§

fn add(self, rhs: FixedU128) -> <FixedU128 as Add>::Output

Performs the + operation. Read more
Source§

impl Bounded for FixedU128

Source§

fn min_value() -> FixedU128

Returns the smallest finite number this type can represent
Source§

fn max_value() -> FixedU128

Returns the largest finite number this type can represent
Source§

impl CheckedAdd for FixedU128

Source§

fn checked_add(&self, rhs: &FixedU128) -> Option<FixedU128>

Adds two numbers, checking for overflow. If overflow happens, None is returned.
Source§

impl CheckedDiv for FixedU128

Source§

fn checked_div(&self, other: &FixedU128) -> Option<FixedU128>

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.
Source§

impl CheckedMul for FixedU128

Source§

fn checked_mul(&self, other: &FixedU128) -> Option<FixedU128>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
Source§

impl CheckedSub for FixedU128

Source§

fn checked_sub(&self, rhs: &FixedU128) -> Option<FixedU128>

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
Source§

impl Clone for FixedU128

Source§

fn clone(&self) -> FixedU128

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CompactAs for FixedU128

Source§

type As = u128

A compact-encodable type that should be used as the encoding.
Source§

fn encode_as(&self) -> &u128

Returns the compact-encodable type.
Source§

fn decode_from(x: u128) -> Result<FixedU128, Error>

Decode Self from the compact-decoded type.
Source§

impl Debug for FixedU128

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Decode for FixedU128

Source§

fn decode<__CodecInputEdqy>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<FixedU128, Error>
where __CodecInputEdqy: Input,

Attempt to deserialise the value from input.
Source§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
Source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl Default for FixedU128

Source§

fn default() -> FixedU128

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FixedU128

Source§

fn deserialize<D>( deserializer: D, ) -> Result<FixedU128, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for FixedU128

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div for FixedU128

Source§

type Output = FixedU128

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FixedU128) -> <FixedU128 as Div>::Output

Performs the / operation. Read more
Source§

impl Encode for FixedU128

Source§

fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
where __CodecOutputEdqy: Output + ?Sized,

Convert self to a slice and append it to the destination.
Source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
Source§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
Source§

impl FixedPointNumber for FixedU128

Source§

const DIV: <FixedU128 as FixedPointNumber>::Inner = {transmute(0x00000000000000000de0b6b3a7640000): <arithmetic::FixedU128 as arithmetic::FixedPointNumber>::Inner}

Precision of this fixed point implementation. It should be a power of 10.
Source§

const SIGNED: bool = false

Indicates if this fixed point implementation is signed or not.
Source§

type Inner = u128

The underlying data type used for this fixed point number.
Source§

fn from_inner(inner: <FixedU128 as FixedPointNumber>::Inner) -> FixedU128

Builds this type from an integer number.
Source§

fn into_inner(self) -> <FixedU128 as FixedPointNumber>::Inner

Consumes self and returns the inner raw value.
Source§

fn accuracy() -> Self::Inner

Precision of this fixed point implementation.
Source§

fn saturating_from_integer<N>(int: N) -> Self

Creates self from an integer number int. Read more
Source§

fn checked_from_integer(int: Self::Inner) -> Option<Self>

Creates self from an integer number int. Read more
Source§

fn saturating_from_rational<N, D>(n: N, d: D) -> Self

Creates self from a rational number. Equal to n / d. Read more
Source§

fn checked_from_rational<N, D>(n: N, d: D) -> Option<Self>

Creates self from a rational number. Equal to n / d. Read more
Source§

fn checked_mul_int<N>(self, n: N) -> Option<N>

Checked multiplication for integer type N. Equal to self * n. Read more
Source§

fn saturating_mul_int<N>(self, n: N) -> N

Saturating multiplication for integer type N. Equal to self * n. Read more
Source§

fn checked_div_int<N>(self, d: N) -> Option<N>

Checked division for integer type N. Equal to self / d. Read more
Source§

fn saturating_div_int<N>(self, d: N) -> N

Saturating division for integer type N. Equal to self / d. Read more
Source§

fn saturating_mul_acc_int<N>(self, n: N) -> N

Saturating multiplication for integer type N, adding the result back. Equal to self * n + n. Read more
Source§

fn saturating_abs(self) -> Self

Saturating absolute value. Read more
Source§

fn reciprocal(self) -> Option<Self>

Takes the reciprocal (inverse). Equal to 1 / self. Read more
Source§

fn zero() -> Self

Returns zero.
Source§

fn is_zero(&self) -> bool

Checks if the number is zero.
Source§

fn one() -> Self

Returns one.
Source§

fn is_one(&self) -> bool

Checks if the number is one.
Source§

fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.
Source§

fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.
Source§

fn trunc(self) -> Self

Returns the integer part.
Source§

fn frac(self) -> Self

Returns the fractional part. Read more
Source§

fn ceil(self) -> Self

Returns the smallest integer greater than or equal to a number. Read more
Source§

fn floor(self) -> Self

Returns the largest integer less than or equal to a number. Read more
Source§

fn round(self) -> Self

Returns the number rounded to the nearest integer. Rounds half-way cases away from 0.0. Read more
Source§

impl<N, D> From<(N, D)> for FixedU128

Source§

fn from(r: (N, D)) -> FixedU128

Converts to this type from the input type.
Source§

impl From<Compact<FixedU128>> for FixedU128

Source§

fn from(x: Compact<FixedU128>) -> FixedU128

Converts to this type from the input type.
Source§

impl<P> From<P> for FixedU128

Source§

fn from(p: P) -> FixedU128

Converts to this type from the input type.
Source§

impl From<u128> for FixedU128

Source§

fn from(int: u128) -> FixedU128

Converts to this type from the input type.
Source§

impl FromStr for FixedU128

Source§

type Err = &'static str

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<FixedU128, <FixedU128 as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Mul for FixedU128

Source§

type Output = FixedU128

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FixedU128) -> <FixedU128 as Mul>::Output

Performs the * operation. Read more
Source§

impl Neg for FixedU128

Source§

type Output = FixedU128

The resulting type after applying the - operator.
Source§

fn neg(self) -> <FixedU128 as Neg>::Output

Performs the unary - operation. Read more
Source§

impl Ord for FixedU128

Source§

fn cmp(&self, other: &FixedU128) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FixedU128

Source§

fn eq(&self, other: &FixedU128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FixedU128

Source§

fn partial_cmp(&self, other: &FixedU128) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Saturating for FixedU128

Source§

fn saturating_add(self, rhs: FixedU128) -> FixedU128

Saturating addition. Compute self + rhs, saturating at the numeric bounds instead of overflowing.
Source§

fn saturating_sub(self, rhs: FixedU128) -> FixedU128

Saturating subtraction. Compute self - rhs, saturating at the numeric bounds instead of overflowing.
Source§

fn saturating_mul(self, rhs: FixedU128) -> FixedU128

Saturating multiply. Compute self * rhs, saturating at the numeric bounds instead of overflowing.
Source§

fn saturating_pow(self, exp: usize) -> FixedU128

Saturating exponentiation. Compute self.pow(exp), saturating at the numeric bounds instead of overflowing.
Source§

impl Serialize for FixedU128

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub for FixedU128

Source§

type Output = FixedU128

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: FixedU128) -> <FixedU128 as Sub>::Output

Performs the - operation. Read more
Source§

impl Copy for FixedU128

Source§

impl EncodeLike for FixedU128

Source§

impl Eq for FixedU128

Source§

impl StructuralPartialEq for FixedU128

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedConversion for T

Source§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
Source§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
Source§

impl<T> Clear for T
where T: Default + Eq + PartialEq,

Source§

fn is_clear(&self) -> bool

True iff no bits are set.
Source§

fn clear() -> T

Return the value of Self that is clear.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodeAll for T
where T: Decode,

Source§

fn decode_all(input: &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

impl<T> DecodeLimit for T
where T: Decode,

Source§

fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>

Decode Self with the given maximum recursion depth. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HasCompact for T
where T: 'static, Compact<T>: for<'a> EncodeAsRef<'a, T> + Decode + From<T> + Into<T>,

Source§

type Type = Compact<T>

The compact type; this can be
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

Source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

Source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

Source§

impl<T> KeyedVec for T
where T: Codec,

Source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
Source§

impl<T> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatedConversion for T

Source§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
Source§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

Source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
Source§

impl<T, S> UniqueSaturatedFrom<T> for S
where S: TryFrom<T> + Bounded,

Source§

fn unique_saturated_from(t: T) -> S

Convert from a value of T into an equivalent instance of Self.
Source§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

Source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
Source§

impl<T> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S> Codec for S
where S: Decode + Encode,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> EncodeLike<&&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

Source§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

Source§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

Source§

impl<'a, T> EncodeLike<Cow<'a, T>> for T
where T: ToOwned + Encode,

Source§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

Source§

impl<T> Error for T
where T: 'static + Debug + Display + Send + Sync,

Source§

impl<S> FullCodec for S
where S: Decode + FullEncode,

Source§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

Source§

impl<T> MaybeDebug for T
where T: Debug,

Source§

impl<T> MaybeDebug for T
where T: Debug,

Source§

impl<T> MaybeDisplay for T
where T: Display,

Source§

impl<T> MaybeFromStr for T
where T: FromStr,

Source§

impl<T> MaybeRefUnwindSafe for T
where T: RefUnwindSafe,

Source§

impl<T> MaybeSerialize for T
where T: Serialize,

Source§

impl<T> MaybeSerializeDeserialize for T

Source§

impl<T> Member for T
where T: Send + Sync + Debug + Eq + PartialEq + Clone + 'static,