pub struct U256(/* private fields */);
Expand description
256-bit unsigned integer
Implementations§
source§impl U256
impl U256
sourcepub const MIDDLE: Self = _
pub const MIDDLE: Self = _
The middle of the piece distance field.
The analogue of 0b1000_0000
for u8
.
sourcepub fn from_be_bytes(bytes: [u8; 32]) -> Self
pub fn from_be_bytes(bytes: [u8; 32]) -> Self
Create from big endian bytes
sourcepub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Convert to big endian bytes
sourcepub fn from_le_bytes(bytes: [u8; 32]) -> Self
pub fn from_le_bytes(bytes: [u8; 32]) -> Self
Create from little endian bytes
sourcepub fn to_le_bytes(self) -> [u8; 32]
pub fn to_le_bytes(self) -> [u8; 32]
Convert to little endian bytes
sourcepub fn checked_add(&self, v: &Self) -> Option<Self>
pub fn checked_add(&self, v: &Self) -> Option<Self>
Adds two numbers, checking for overflow. If overflow happens, None
is returned.
sourcepub fn checked_sub(&self, v: &Self) -> Option<Self>
pub fn checked_sub(&self, v: &Self) -> Option<Self>
Subtracts two numbers, checking for underflow. If underflow happens, None
is returned.
sourcepub fn checked_mul(&self, v: &Self) -> Option<Self>
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.
sourcepub fn checked_div(&self, v: &Self) -> Option<Self>
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.
sourcepub fn saturating_add(&self, v: &Self) -> Self
pub fn saturating_add(&self, v: &Self) -> Self
Saturating addition. Computes self + other
, saturating at the relevant high or low
boundary of the type.
sourcepub fn saturating_sub(&self, v: &Self) -> Self
pub fn saturating_sub(&self, v: &Self) -> Self
Saturating subtraction. Computes self - other
, saturating at the relevant high or low
boundary of the type.
sourcepub fn saturating_mul(&self, v: &Self) -> Self
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 Decode for U256
impl Decode for U256
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
source§impl Encode for U256
impl Encode for U256
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
source§fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>(
&self,
f: __CodecUsingEncodedCallback,
) -> __CodecOutputReturn
fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>( &self, f: __CodecUsingEncodedCallback, ) -> __CodecOutputReturn
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl Ord for U256
impl Ord for U256
source§impl PartialOrd for U256
impl PartialOrd for U256
source§impl WrappingAdd for U256
impl WrappingAdd for U256
source§fn wrapping_add(&self, other: &Self) -> Self
fn wrapping_add(&self, other: &Self) -> Self
self + other
, wrapping around at the boundary of
the type.source§impl WrappingSub for U256
impl WrappingSub for U256
source§fn wrapping_sub(&self, other: &Self) -> Self
fn wrapping_sub(&self, other: &Self) -> Self
self - other
, wrapping around at the boundary
of the type.impl Copy for U256
impl EncodeLike for U256
impl Eq for U256
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> DecodeAll for Twhere
T: Decode,
impl<T> DecodeAll for Twhere
T: Decode,
§fn decode_all(input: &mut &[u8]) -> Result<T, Error>
fn decode_all(input: &mut &[u8]) -> Result<T, Error>
Self
and consume all of the given input data. Read more§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 Twhere
T: Codec,
impl<T> KeyedVec for Twhere
T: Codec,
§fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
Self
prepended by given slice.