pub struct U256(/* private fields */);Expand description
IcyDB-owned fixed-width unsigned 256-bit scalar.
Runtime values are inline and allocation-free. Candid exposes this type as
nat; ingress rejects values greater than U256::MAX. Persistence and
index encodings are owned separately by IcyDB.
Implementations§
Source§impl U256
impl U256
Sourcepub const fn from_words(high: u128, low: u128) -> U256
pub const fn from_words(high: u128, low: u128) -> U256
Build from two 128-bit words in numeric high/low order.
Sourcepub const fn into_words(self) -> (u128, u128)
pub const fn into_words(self) -> (u128, u128)
Split into two 128-bit words in numeric high/low order.
Sourcepub fn from_be_bytes(bytes: [u8; 32]) -> U256
pub fn from_be_bytes(bytes: [u8; 32]) -> U256
Build from exactly 32 unsigned big-endian bytes.
Sourcepub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Return exactly 32 unsigned big-endian bytes.
Sourcepub fn checked_add(self, rhs: U256) -> Option<U256>
pub fn checked_add(self, rhs: U256) -> Option<U256>
Add two values, returning None on unsigned 256-bit overflow.
Sourcepub fn checked_sub(self, rhs: U256) -> Option<U256>
pub fn checked_sub(self, rhs: U256) -> Option<U256>
Subtract two values, returning None on unsigned 256-bit underflow.
Sourcepub fn checked_mul(self, rhs: U256) -> Option<U256>
pub fn checked_mul(self, rhs: U256) -> Option<U256>
Multiply two values, returning None on unsigned 256-bit overflow.
Sourcepub fn checked_div(self, rhs: U256) -> Option<U256>
pub fn checked_div(self, rhs: U256) -> Option<U256>
Divide two values, returning None when the divisor is zero.
Sourcepub fn checked_rem(self, rhs: U256) -> Option<U256>
pub fn checked_rem(self, rhs: U256) -> Option<U256>
Return the remainder, or None when the divisor is zero.
Trait Implementations§
Source§impl CandidType for U256
impl CandidType for U256
impl Copy for U256
Source§impl<'de> Deserialize<'de> for U256
impl<'de> Deserialize<'de> for U256
Source§fn deserialize<D>(
deserializer: D,
) -> Result<U256, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<U256, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for U256
Source§impl NormalizeAuto for U256
impl NormalizeAuto for U256
fn normalize_self(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl NormalizeCustom for U256
impl NormalizeCustom for U256
fn normalize_custom(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl NumericValue for U256
impl NumericValue for U256
Source§impl Ord for U256
impl Ord for U256
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for U256
impl PartialOrd for U256
Source§impl Serialize for U256
impl Serialize for U256
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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
impl StructuralPartialEq for U256
Source§impl ValidateAuto for U256
impl ValidateAuto for U256
fn validate_self(&self, _ctx: &mut dyn VisitorContext)
Source§impl ValidateCustom for U256
impl ValidateCustom for U256
fn validate_custom(&self, _ctx: &mut dyn VisitorContext)
Auto Trait Implementations§
impl Freeze for U256
impl RefUnwindSafe for U256
impl Send for U256
impl Sync for U256
impl Unpin for U256
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> CustomError for T
impl<T> CustomError for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> Normalize for Twhere
T: NormalizeAuto + NormalizeCustom,
Source§impl<T> NormalizeAndValidate for Twhere
T: Visitable,
impl<T> NormalizeAndValidate for Twhere
T: Visitable,
Source§fn normalize_and_validate(self) -> Result<Self, VisitorError>
fn normalize_and_validate(self) -> Result<Self, VisitorError>
Normalize and then validate this application-owned value. Read more