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. Human-readable Serde uses
decimal text; binary Serde uses u64 or tagged little-endian magnitude bytes.
Implementations§
Source§impl U256
impl U256
Sourcepub const fn from_words(high: u128, low: u128) -> Self
pub const fn from_words(high: u128, low: u128) -> Self
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]) -> Self
pub fn from_be_bytes(bytes: [u8; 32]) -> Self
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: Self) -> Option<Self>
pub fn checked_add(self, rhs: Self) -> Option<Self>
Add two values, returning None on unsigned 256-bit overflow.
Sourcepub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
Subtract two values, returning None on unsigned 256-bit underflow.
Sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Multiply two values, returning None on unsigned 256-bit overflow.
Sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Divide two values, returning None when the divisor is zero.
Sourcepub fn checked_rem(self, rhs: Self) -> Option<Self>
pub fn checked_rem(self, rhs: Self) -> Option<Self>
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<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for U256
Source§impl NumericValue for U256
impl NumericValue for U256
Source§fn try_to_decimal(&self) -> Option<Decimal>
fn try_to_decimal(&self) -> Option<Decimal>
Decimal for generic numeric handling.Source§fn try_from_decimal(value: Decimal) -> Option<Self>
fn try_from_decimal(value: Decimal) -> Option<Self>
Decimal after generic numeric handling.