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: Nat) -> NatBig
pub const fn from_candid(value: Nat) -> NatBig
Construct from the canonical Candid natural-number representation.
Sourcepub fn from_biguint(value: BigUint) -> NatBig
pub fn from_biguint(value: BigUint) -> NatBig
Construct from a num_bigint unsigned integer.
Sourcepub fn u32_digits(&self) -> impl DoubleEndedIterator + ExactSizeIterator
pub fn u32_digits(&self) -> impl DoubleEndedIterator + 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: NatBig) -> NatBig
pub fn saturating_add(self, rhs: NatBig) -> NatBig
Saturating addition (unbounded; equivalent to normal addition).
Sourcepub fn saturating_sub(self, rhs: NatBig) -> NatBig
pub fn saturating_sub(self, rhs: NatBig) -> NatBig
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: NatBig)
fn add_assign(&mut self, __rhs: NatBig)
+= 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: D,
) -> Result<NatBig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<NatBig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl DivAssign for NatBig
impl DivAssign for NatBig
Source§fn div_assign(&mut self, other: NatBig)
fn div_assign(&mut self, other: NatBig)
/= operation. Read moreimpl Eq for NatBig
Source§impl MulAssign for NatBig
impl MulAssign for NatBig
Source§fn mul_assign(&mut self, other: NatBig)
fn mul_assign(&mut self, other: NatBig)
*= operation. Read moreSource§impl NormalizeAuto for NatBig
impl NormalizeAuto for NatBig
fn normalize_self(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl NormalizeCustom for NatBig
impl NormalizeCustom for NatBig
fn normalize_custom(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl NumericValue for NatBig
impl NumericValue for NatBig
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
Source§impl Serialize for NatBig
impl Serialize for NatBig
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,
impl StructuralPartialEq for NatBig
Source§impl SubAssign for NatBig
impl SubAssign for NatBig
Source§fn sub_assign(&mut self, __rhs: NatBig)
fn sub_assign(&mut self, __rhs: NatBig)
-= operation. Read moreSource§impl ValidateAuto for NatBig
impl ValidateAuto for NatBig
fn validate_self(&self, _ctx: &mut dyn VisitorContext)
Source§impl ValidateCustom for NatBig
impl ValidateCustom for NatBig
fn validate_custom(&self, _ctx: &mut dyn VisitorContext)
Auto Trait Implementations§
impl Freeze for NatBig
impl RefUnwindSafe for NatBig
impl Send for NatBig
impl Sync for NatBig
impl Unpin for NatBig
impl UnsafeUnpin for NatBig
impl UnwindSafe for NatBig
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§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
key and return true if they are equal.