pub struct Tokens(/* private fields */);Expand description
Variable-length 120-bit integer. Used for native currencies.
Stored as 4 bits of len (0..=15), followed by len bytes.
Implementations§
Source§impl Tokens
impl Tokens
Sourcepub const fn into_inner(self) -> u128
pub const fn into_inner(self) -> u128
Converts integer into an underlying primitive integer.
Sourcepub const fn is_valid(&self) -> bool
pub const fn is_valid(&self) -> bool
Returns true if an underlying primitive integer fits into the repr.
Sourcepub const fn bit_len(&self) -> Option<u16>
pub const fn bit_len(&self) -> Option<u16>
Returns number of data bits that this struct occupies.
Returns None if an underlying primitive integer is too large.
Sourcepub const fn unwrap_bit_len(&self) -> u16
pub const fn unwrap_bit_len(&self) -> u16
Returns number of data bits that this struct occupies.
Returns MAX_BITS if an underlying primitive integer is too large.
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Saturating integer addition. Computes self + rhs,
saturating at the numeric bounds instead of overflowing.
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Saturating integer addition. Computes self - rhs,
saturating at the numeric bounds instead of overflowing.
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Saturating integer multiplication. Computes self * rhs,
returning None if overflow occurred.
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Computes self + rhs, returning None if overflow occurred.
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Computes self / rhs, returning None if rhs == 0
or overflow occurred.
Sourcepub fn try_add_assign(&mut self, other: Self) -> Result<(), Error>
pub fn try_add_assign(&mut self, other: Self) -> Result<(), Error>
Tries to add an other value to the current one.
Sourcepub fn try_sub_assign(&mut self, other: Self) -> Result<(), Error>
pub fn try_sub_assign(&mut self, other: Self) -> Result<(), Error>
Tries to subtract an other value from the current one.
Sourcepub fn try_mul_assign(&mut self, other: Self) -> Result<(), Error>
pub fn try_mul_assign(&mut self, other: Self) -> Result<(), Error>
Tries to multiply the current value by the other value.
Sourcepub fn try_div_assign(&mut self, other: Self) -> Result<(), Error>
pub fn try_div_assign(&mut self, other: Self) -> Result<(), Error>
Tries to divice the current value by the other value.
Trait Implementations§
Source§impl AddAssign<u128> for Tokens
impl AddAssign<u128> for Tokens
Source§fn add_assign(&mut self, rhs: u128)
fn add_assign(&mut self, rhs: u128)
+= operation. Read moreSource§impl AddAssign for Tokens
impl AddAssign for Tokens
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Tokens
impl<'de> Deserialize<'de> for Tokens
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>,
Source§impl DivAssign<u128> for Tokens
impl DivAssign<u128> for Tokens
Source§fn div_assign(&mut self, rhs: u128)
fn div_assign(&mut self, rhs: u128)
/= operation. Read moreSource§impl DivAssign for Tokens
impl DivAssign for Tokens
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl ExactSize for Tokens
impl ExactSize for Tokens
Source§fn exact_size(&self) -> Size
fn exact_size(&self) -> Size
Source§impl From<Tokens> for CurrencyCollection
impl From<Tokens> for CurrencyCollection
Source§impl MulAssign<u128> for Tokens
impl MulAssign<u128> for Tokens
Source§fn mul_assign(&mut self, rhs: u128)
fn mul_assign(&mut self, rhs: u128)
*= operation. Read moreSource§impl MulAssign for Tokens
impl MulAssign for Tokens
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl Ord for Tokens
impl Ord for Tokens
Source§impl PartialOrd for Tokens
impl PartialOrd for Tokens
Source§impl ShlAssign<u8> for Tokens
impl ShlAssign<u8> for Tokens
Source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
<<= operation. Read moreSource§impl ShrAssign<u8> for Tokens
impl ShrAssign<u8> for Tokens
Source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
>>= operation. Read moreSource§impl Store for Tokens
impl Store for Tokens
Source§fn store_into(
&self,
builder: &mut CellBuilder,
_: &dyn CellContext,
) -> Result<(), Error>
fn store_into( &self, builder: &mut CellBuilder, _: &dyn CellContext, ) -> Result<(), Error>
Source§impl SubAssign<u128> for Tokens
impl SubAssign<u128> for Tokens
Source§fn sub_assign(&mut self, rhs: u128)
fn sub_assign(&mut self, rhs: u128)
-= operation. Read moreSource§impl SubAssign for Tokens
impl SubAssign for Tokens
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreimpl Copy for Tokens
impl Eq for Tokens
impl StructuralPartialEq for Tokens
Auto Trait Implementations§
impl Freeze for Tokens
impl RefUnwindSafe for Tokens
impl Send for Tokens
impl Sync for Tokens
impl Unpin for Tokens
impl UnwindSafe for Tokens
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<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
self to key and returns true if they are equal.