#[repr(C)]pub struct Uint<const N: usize>(/* private fields */);
Expand description
A structure that represents large integers and provides basic arithmetic.
It accepts a const generic N
which controls the number of u64s used to
represent the number.
Implementations§
Source§impl<const N: usize> Uint<N>
impl<const N: usize> Uint<N>
Sourcepub fn from_u64_array(data: [u64; N]) -> Self
pub fn from_u64_array(data: [u64; N]) -> Self
Build a Uint from a u64 array
Sourcepub fn to_le_bytes(&self) -> Vec<u8> ⓘ
pub fn to_le_bytes(&self) -> Vec<u8> ⓘ
To litte-endian byte array
Sourcepub fn to_be_bytes(&self) -> Vec<u8> ⓘ
pub fn to_be_bytes(&self) -> Vec<u8> ⓘ
To big-endian byte array
Sourcepub fn from_le_bytes(bytes: impl AsRef<[u8]>) -> StacksResult<Self>
pub fn from_le_bytes(bytes: impl AsRef<[u8]>) -> StacksResult<Self>
Build from a little-endian hex string (padding expected)
Sourcepub fn from_be_bytes(bytes: impl AsRef<[u8]>) -> StacksResult<Self>
pub fn from_be_bytes(bytes: impl AsRef<[u8]>) -> StacksResult<Self>
Build from a big-endian hex string (padding expected)
Sourcepub fn from_le_hex(data: impl AsRef<str>) -> StacksResult<Self>
pub fn from_le_hex(data: impl AsRef<str>) -> StacksResult<Self>
Build from a little-endian hex string
Sourcepub fn from_be_hex(data: impl AsRef<str>) -> StacksResult<Self>
pub fn from_be_hex(data: impl AsRef<str>) -> StacksResult<Self>
Build from a big-endian hex string
Sourcepub fn from_uint<const M: usize>(source: impl AsRef<Uint<M>>) -> Self
pub fn from_uint<const M: usize>(source: impl AsRef<Uint<M>>) -> Self
Create a new Uint from the provided Uint
Sourcepub fn from_uint_lossy<const M: usize>(source: impl AsRef<Uint<M>>) -> Self
pub fn from_uint_lossy<const M: usize>(source: impl AsRef<Uint<M>>) -> Self
Create a new Uint from the provided Uint, truncating if necessary
Sourcepub fn to_uint_lossy<const M: usize>(&self) -> Uint<M>
pub fn to_uint_lossy<const M: usize>(&self) -> Uint<M>
Convert to a smaller Uint, truncating if necessary
Trait Implementations§
Source§impl<const N: usize> Codec for Uint<N>
impl<const N: usize> Codec for Uint<N>
Source§fn codec_deserialize<R: Read>(data: &mut R) -> Result<Self>where
Self: Sized,
fn codec_deserialize<R: Read>(data: &mut R) -> Result<Self>where
Self: Sized,
Deserialize from a reader
Source§fn serialize<W: Write>(&self, dest: &mut W) -> StacksResult<()>
fn serialize<W: Write>(&self, dest: &mut W) -> StacksResult<()>
Serialize to a writer and return a StacksResult
Source§fn deserialize<R: Read>(data: &mut R) -> StacksResult<Self>where
Self: Sized,
fn deserialize<R: Read>(data: &mut R) -> StacksResult<Self>where
Self: Sized,
Deserialize from a reader and return a StacksResult
Source§impl<'de, const N: usize> Deserialize<'de> for Uint<N>
impl<'de, const N: usize> Deserialize<'de> for Uint<N>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const N: usize> Ord for Uint<N>
impl<const N: usize> Ord for Uint<N>
Source§impl<const N: usize> PartialOrd for Uint<N>
impl<const N: usize> PartialOrd for Uint<N>
impl<const N: usize> Copy for Uint<N>
impl<const N: usize> Eq for Uint<N>
impl<const N: usize> StructuralPartialEq for Uint<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Uint<N>
impl<const N: usize> RefUnwindSafe for Uint<N>
impl<const N: usize> Send for Uint<N>
impl<const N: usize> Sync for Uint<N>
impl<const N: usize> Unpin for Uint<N>
impl<const N: usize> UnwindSafe for Uint<N>
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