Struct Perquintill

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

Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].

Parts per Quintillion

Implementations§

Source§

impl Perquintill

Source

pub const fn from_parts(parts: u64) -> Perquintill

From an explicitly defined number of parts per maximum of the type.

Source

pub const fn from_percent(x: u64) -> Perquintill

Converts a percent into Self. Equal to x / 100.

This can be created at compile time.

Source

pub const fn one() -> Perquintill

Source

pub fn is_one(&self) -> bool

Source

pub const fn zero() -> Perquintill

Source

pub fn is_zero(&self) -> bool

Source

pub const fn deconstruct(self) -> u64

Source

pub fn square(self) -> Perquintill

Source

pub fn from_fraction(x: f64) -> Perquintill

Source

pub fn from_rational_approximation<N>(p: N, q: N) -> Perquintill
where N: Clone + Ord + TryInto<u64> + TryInto<u128> + Div<Output = N> + Rem<Output = N> + Add<Output = N> + Unsigned, u64: Into<N>,

Source

pub fn mul_floor<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<u64> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Unsigned, u64: Into<N>,

Source

pub fn mul_ceil<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<u64> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Unsigned, u64: Into<N>,

Source

pub fn saturating_reciprocal_mul<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<u64> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, u64: Into<N>,

Source

pub fn saturating_reciprocal_mul_floor<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<u64> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, u64: Into<N>,

Source

pub fn saturating_reciprocal_mul_ceil<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<u64> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, u64: Into<N>,

Source§

impl Perquintill

Source

pub const fn from_perthousand(x: u64) -> Perquintill

Converts a percent into Self. Equal to x / 1000.

This can be created at compile time.

Trait Implementations§

Source§

impl Bounded for Perquintill

Source§

fn min_value() -> Perquintill

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Perquintill

Returns the largest finite number this type can represent
Source§

impl Clone for Perquintill

Source§

fn clone(&self) -> Perquintill

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 Perquintill

Implementation makes any compact encoding of PerThing::Inner valid, when decoding it will saturate up to PerThing::ACCURACY.

Source§

type As = u64

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

fn encode_as(&self) -> &<Perquintill as CompactAs>::As

Returns the compact-encodable type.
Source§

fn decode_from(x: <Perquintill as CompactAs>::As) -> Result<Perquintill, Error>

Decode Self from the compact-decoded type.
Source§

impl Debug for Perquintill

Source§

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

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

impl Decode for Perquintill

Source§

fn decode<I>(input: &mut I) -> Result<Perquintill, Error>
where I: 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 Perquintill

Source§

fn default() -> Perquintill

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

impl<'de> Deserialize<'de> for Perquintill

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Perquintill, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl Div for Perquintill

Source§

type Output = Perquintill

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Encode for Perquintill

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 From<Compact<Perquintill>> for Perquintill

Source§

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

Converts to this type from the input type.
Source§

impl<N> Mul<N> for Perquintill
where N: Div<Output = N> + Clone + Mul<Output = N> + UniqueSaturatedInto<u64> + Add<Output = N> + Rem<Output = N> + Unsigned, u64: Into<N>,

Non-overflow multiplication.

This is tailored to be used with a balance type.

Source§

type Output = N

The resulting type after applying the * operator.
Source§

fn mul(self, b: N) -> <Perquintill as Mul<N>>::Output

Performs the * operation. Read more
Source§

impl Ord for Perquintill

Source§

fn cmp(&self, other: &Perquintill) -> 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 Perquintill

Source§

fn eq(&self, other: &Perquintill) -> 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 Perquintill

Source§

fn partial_cmp(&self, other: &Perquintill) -> 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 PerThing for Perquintill

Source§

fn deconstruct(self) -> <Perquintill as PerThing>::Inner

Consume self and return the number of parts per thing.

Source§

fn from_parts(parts: <Perquintill as PerThing>::Inner) -> Perquintill

Build this type from a number of parts per thing.

Source§

fn from_fraction(x: f64) -> Perquintill

NOTE: saturate to 0 or 1 if x is beyond [0, 1]

Source§

const ACCURACY: <Perquintill as PerThing>::Inner = {transmute(0x0de0b6b3a7640000): <arithmetic::Perquintill as arithmetic::PerThing>::Inner}

The accuracy of this type.
Source§

type Inner = u64

The data type used to build this per-thingy.
Source§

type Upper = u128

A data type larger than Self::Inner, used to avoid overflow in some computations. It must be able to compute ACCURACY^2.
Source§

fn from_rational_approximation<N>(p: N, q: N) -> Perquintill
where N: Clone + Ord + TryInto<<Perquintill as PerThing>::Inner> + TryInto<<Perquintill as PerThing>::Upper> + Div<Output = N> + Rem<Output = N> + Add<Output = N> + Unsigned + Zero + One, <Perquintill as PerThing>::Inner: Into<N>,

Approximate the fraction p/q into a per-thing fraction. This will never overflow. Read more
Source§

fn zero() -> Self

Equivalent to Self::from_parts(0).
Source§

fn is_zero(&self) -> bool

Return true if this is nothing.
Source§

fn one() -> Self

Equivalent to Self::from_parts(Self::ACCURACY).
Source§

fn is_one(&self) -> bool

Return true if this is one.
Source§

fn from_percent(x: Self::Inner) -> Self

Build this type from a percent. Equivalent to Self::from_parts(x * Self::ACCURACY / 100) but more accurate and can cope with potential type overflows.
Source§

fn square(self) -> Self

Return the product of multiplication of this value by itself.
Source§

fn mul_floor<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<Self::Inner> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Unsigned, Self::Inner: Into<N>,

Multiplication that always rounds down to a whole number. The standard Mul rounds to the nearest whole number. Read more
Source§

fn mul_ceil<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<Self::Inner> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Unsigned, Self::Inner: Into<N>,

Multiplication that always rounds the result up to a whole number. The standard Mul rounds to the nearest whole number. Read more
Source§

fn saturating_reciprocal_mul<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<Self::Inner> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, Self::Inner: Into<N>,

Saturating multiplication by the reciprocal of self. The result is rounded to the nearest whole number and saturates at the numeric bounds instead of overflowing. Read more
Source§

fn saturating_reciprocal_mul_floor<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<Self::Inner> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, Self::Inner: Into<N>,

Saturating multiplication by the reciprocal of self. The result is rounded down to the nearest whole number and saturates at the numeric bounds instead of overflowing. Read more
Source§

fn saturating_reciprocal_mul_ceil<N>(self, b: N) -> N
where N: Clone + UniqueSaturatedInto<Self::Inner> + Rem<Output = N> + Div<Output = N> + Mul<Output = N> + Add<Output = N> + Saturating + Unsigned, Self::Inner: Into<N>,

Saturating multiplication by the reciprocal of self. The result is rounded up to the nearest whole number and saturates at the numeric bounds instead of overflowing. Read more
Source§

impl Saturating for Perquintill

Source§

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

Saturating addition. Compute self + rhs, saturating at the numeric bounds instead of overflowing. This operation is lossless if it does not saturate.

Source§

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

Saturating subtraction. Compute self - rhs, saturating at the numeric bounds instead of overflowing. This operation is lossless if it does not saturate.

Source§

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

Saturating multiply. Compute self * rhs, saturating at the numeric bounds instead of overflowing. This operation is lossy.

Source§

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

Saturating exponentiation. Computes self.pow(exp), saturating at the numeric bounds instead of overflowing. This operation is lossy.

Source§

impl Serialize for Perquintill

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 Copy for Perquintill

Source§

impl EncodeLike for Perquintill

Source§

impl Eq for Perquintill

Source§

impl StructuralPartialEq for Perquintill

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, 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<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> 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,