subspace_core_primitives

Struct U256

source
pub struct U256(/* private fields */);
Expand description

256-bit unsigned integer

Implementations§

source§

impl U256

source

pub const MIDDLE: Self = _

The middle of the piece distance field. The analogue of 0b1000_0000 for u8.

source

pub const MAX: Self = _

Maximum value.

source

pub const fn zero() -> Self

Zero (additive identity) of this type.

source

pub fn one() -> Self

One (multiplicative identity) of this type.

source

pub fn from_be_bytes(bytes: [u8; 32]) -> Self

Create from big endian bytes

source

pub fn to_be_bytes(self) -> [u8; 32]

Convert to big endian bytes

source

pub fn from_le_bytes(bytes: [u8; 32]) -> Self

Create from little endian bytes

source

pub fn to_le_bytes(self) -> [u8; 32]

Convert to little endian bytes

source

pub fn checked_add(&self, v: &Self) -> Option<Self>

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

source

pub fn checked_sub(&self, v: &Self) -> Option<Self>

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

source

pub fn checked_mul(&self, v: &Self) -> Option<Self>

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

source

pub fn checked_div(&self, v: &Self) -> Option<Self>

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

source

pub fn saturating_add(&self, v: &Self) -> Self

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.

source

pub fn saturating_sub(&self, v: &Self) -> Self

Saturating subtraction. Computes self - other, saturating at the relevant high or low boundary of the type.

source

pub fn saturating_mul(&self, v: &Self) -> Self

Saturating multiplication. Computes self * other, saturating at the relevant high or low boundary of the type.

Trait Implementations§

source§

impl Add for U256

source§

type Output = U256

The resulting type after applying the + operator.
source§

fn add(self, rhs: U256) -> U256

Performs the + operation. Read more
source§

impl Clone for U256

source§

fn clone(&self) -> U256

Returns a copy 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 Debug for U256

source§

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

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

impl Decode for U256

source§

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

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

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

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

fn encoded_fixed_size() -> Option<usize>

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

impl Default for U256

source§

fn default() -> Self

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

impl Display for U256

source§

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

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

impl<__RhsT> Div<__RhsT> for U256
where U256: Div<__RhsT, Output = U256>,

source§

type Output = U256

The resulting type after applying the / operator.
source§

fn div(self, rhs: __RhsT) -> U256

Performs the / operation. Read more
source§

impl Encode for U256

source§

fn size_hint(&self) -> usize

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

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

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<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>( &self, f: __CodecUsingEncodedCallback, ) -> __CodecOutputReturn

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

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl From<u128> for U256

source§

fn from(number: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for U256

source§

fn from(number: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for U256

source§

fn from(number: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for U256

source§

fn from(number: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for U256

source§

fn from(number: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for U256

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<__RhsT> Mul<__RhsT> for U256
where U256: Mul<__RhsT, Output = U256>,

source§

type Output = U256

The resulting type after applying the * operator.
source§

fn mul(self, rhs: __RhsT) -> U256

Performs the * operation. Read more
source§

impl Ord for U256

source§

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

source§

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

source§

fn partial_cmp(&self, other: &U256) -> 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<__RhsT> Rem<__RhsT> for U256
where U256: Rem<__RhsT, Output = U256>,

source§

type Output = U256

The resulting type after applying the % operator.
source§

fn rem(self, rhs: __RhsT) -> U256

Performs the % operation. Read more
source§

impl Sub for U256

source§

type Output = U256

The resulting type after applying the - operator.
source§

fn sub(self, rhs: U256) -> U256

Performs the - operation. Read more
source§

impl TryFrom<U256> for u16

source§

type Error = &'static str

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

fn try_from(value: U256) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U256> for u32

source§

type Error = &'static str

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

fn try_from(value: U256) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U256> for u64

source§

type Error = &'static str

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

fn try_from(value: U256) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U256> for u8

source§

type Error = &'static str

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

fn try_from(value: U256) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TypeInfo for U256

source§

type Identity = U256

The type identifying for which type info is provided. Read more
source§

fn type_info() -> Type

Returns the static type identifier for Self.
source§

impl WrappingAdd for U256

source§

fn wrapping_add(&self, other: &Self) -> Self

Wrapping (modular) addition. Computes self + other, wrapping around at the boundary of the type.
source§

impl WrappingSub for U256

source§

fn wrapping_sub(&self, other: &Self) -> Self

Wrapping (modular) subtraction. Computes self - other, wrapping around at the boundary of the type.
source§

impl Copy for U256

source§

impl EncodeLike for U256

source§

impl Eq for U256

source§

impl StructuralPartialEq for U256

Auto Trait Implementations§

§

impl Freeze for U256

§

impl RefUnwindSafe for U256

§

impl Send for U256

§

impl Sync for U256

§

impl Unpin for U256

§

impl UnwindSafe for U256

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

§

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

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

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

§

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

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

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

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

§

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

Return an encoding of Self prepended by given slice.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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§

default 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.
§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<T> JsonSchemaMaybe for T

§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,