pub struct NatBig(/* private fields */);Expand description
Arbitrary-precision unsigned integer used by schema and typed values.
Candid uses its native integer type; human-readable Serde uses decimal text. Binary Serde uses native small integers and tagged little-endian wide bytes.
Implementations§
Source§impl NatBig
impl NatBig
Sourcepub fn magnitude_bits(&self) -> u64
pub fn magnitude_bits(&self) -> u64
Return the magnitude’s bit length without allocating an encoded copy.
Sourcepub fn leb128_len(&self) -> u64
pub fn leb128_len(&self) -> u64
Return the exact unsigned LEB128 byte length without allocating or encoding.
Sourcepub const fn from_candid(value: WrappedNat) -> Self
pub const fn from_candid(value: WrappedNat) -> Self
Construct from the canonical Candid natural-number representation.
Sourcepub fn from_biguint(value: BigUint) -> Self
pub fn from_biguint(value: BigUint) -> Self
Construct from a num_bigint unsigned integer.
Sourcepub fn u32_digits(
&self,
) -> impl DoubleEndedIterator<Item = u32> + ExactSizeIterator + '_
pub fn u32_digits( &self, ) -> impl DoubleEndedIterator<Item = u32> + ExactSizeIterator + '_
Borrow little-endian base-2^32 limbs without allocation.
Sourcepub fn to_leb128(&self) -> Vec<u8> ⓘ
pub fn to_leb128(&self) -> Vec<u8> ⓘ
Serialize this arbitrary-precision natural for internal hash and sort-key framing.
Sourcepub fn leb128_bytes(&self) -> impl Iterator<Item = u8> + '_
pub fn leb128_bytes(&self) -> impl Iterator<Item = u8> + '_
Iterate canonical unsigned LEB128 bytes with constant scratch and no allocation.
Sourcepub fn saturating_add(self, rhs: Self) -> Self
pub fn saturating_add(self, rhs: Self) -> Self
Saturating addition (unbounded; equivalent to normal addition).
Sourcepub fn saturating_sub(self, rhs: Self) -> Self
pub fn saturating_sub(self, rhs: Self) -> Self
Saturating subtraction; clamps at zero on underflow.
Trait Implementations§
Source§impl AddAssign for NatBig
impl AddAssign for NatBig
Source§fn add_assign(&mut self, __rhs: Self)
fn add_assign(&mut self, __rhs: Self)
+= operation. Read moreSource§impl CandidType for NatBig
impl CandidType for NatBig
Source§impl<'de> Deserialize<'de> for NatBig
impl<'de> Deserialize<'de> for NatBig
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl DivAssign for NatBig
impl DivAssign for NatBig
Source§fn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
/= operation. Read moreimpl Eq for NatBig
Source§impl MulAssign for NatBig
impl MulAssign for NatBig
Source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
*= operation. Read moreSource§impl NumericValue for NatBig
impl NumericValue for NatBig
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.Source§impl Ord for NatBig
impl Ord for NatBig
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NatBig
impl PartialOrd for NatBig
impl StructuralPartialEq for NatBig
Source§impl SubAssign for NatBig
impl SubAssign for NatBig
Source§fn sub_assign(&mut self, __rhs: Self)
fn sub_assign(&mut self, __rhs: Self)
-= operation. Read more