pub(super) trait Limbs:
Send
+ Sync
+ Debug
+ Zeroize
+ CtEq
+ CtSelect
+ BitOps
+ Limbs<Wide: Send + Sync + Debug + Zeroize + CtSelect + BitOps + Limbs + Limbs>
+ Limbs {
type Bytes: AsRef<[u8]> + AsMut<[u8]>;
// Required methods
fn max_bits() -> Option<u32>;
fn truncate(wide: Self::Wide, bits: u32) -> Self;
fn widen(thin: Self, wide_bits: u32) -> Self::Wide;
fn to_le_bytes(self) -> Self::Bytes;
fn wide_to_le_bytes(wide: Self::Wide) -> impl AsRef<[u8]>;
fn from_le_slice(bytes: &[u8], max_bits: u32) -> Self;
fn wide_from_le_slice(bytes: &[u8], max_bits: u32) -> Self::Wide;
fn stitch(
first: Self::Bytes,
second: Self::Bytes,
bytes_per_element: usize,
) -> impl AsRef<[u8]>;
}Required Associated Types§
Required Methods§
Sourcefn max_bits() -> Option<u32>
fn max_bits() -> Option<u32>
The maximum amount of bits this value can support.
None signifies this value is unbounded.
Sourcefn truncate(wide: Self::Wide, bits: u32) -> Self
fn truncate(wide: Self::Wide, bits: u32) -> Self
Truncate wide to a member of Self.
bits, a bound on the size of the result, is provided. The value in wide MUST be less than
$2^{bits}$. bits MUST be less than or equal to Self::max_bits() when
Self::max_bits().is_some().
Sourcefn widen(thin: Self, wide_bits: u32) -> Self::Wide
fn widen(thin: Self, wide_bits: u32) -> Self::Wide
Widen thin to a member of Self::Wide.
wide_bits is a bound on how big the widened type should be able to support. The value in
thin MUST be less than $2^{wide_bits}$. wide_bits MUST be less than or equal to
2 * Self::max_bits() when Self::max_bits().is_some().
Sourcefn to_le_bytes(self) -> Self::Bytes
fn to_le_bytes(self) -> Self::Bytes
Convert this number to a sequence of little-endian bytes.
This function MUST run in constant time and yield a result of length constant to the relevant bound.
Sourcefn wide_to_le_bytes(wide: Self::Wide) -> impl AsRef<[u8]>
fn wide_to_le_bytes(wide: Self::Wide) -> impl AsRef<[u8]>
Convert this wide number to a sequence of little-endian bytes.
This function MUST run in constant time and yield a result of length constant to the relevant bound.
Sourcefn from_le_slice(bytes: &[u8], max_bits: u32) -> Self
fn from_le_slice(bytes: &[u8], max_bits: u32) -> Self
Load this number from a sequence of little-endian bytes.
The slice MAY be of arbitrary length so long as the encoded value has bits less than or
equal to max_bits. max_bits MUST be less than or equal to Self::max_bits() when
Self::max_bits().is_some().
Sourcefn wide_from_le_slice(bytes: &[u8], max_bits: u32) -> Self::Wide
fn wide_from_le_slice(bytes: &[u8], max_bits: u32) -> Self::Wide
Load a wide number from a sequence of little-endian bytes.
The slice MAY be of arbitrary length so long as the encoded value has bits less than or
equal to max_bits.max_bits MUST be less than or equal to 2 * Self::max_bits() when
Self::max_bits().is_some().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Limbs for BoxedUint
Available on crate feature alloc only.
impl Limbs for BoxedUint
alloc only.