pub trait IntegerEncodingwhere
Self: Sized,{
type Bytes: ByteArray;
// Required methods
fn to_be_bytes(&self) -> Self::Bytes;
fn to_le_bytes(&self) -> Self::Bytes;
fn from_be_bytes_exact(bytes: &Self::Bytes) -> Option<Self>;
fn from_le_bytes_exact(bytes: &Self::Bytes) -> Option<Self>;
fn from_be_bytes_mod_order(bytes: &[u8]) -> Self;
fn from_le_bytes_mod_order(bytes: &[u8]) -> Self;
}
Expand description
Encodes an integer as bytes
Required Associated Types§
Required Methods§
Sourcefn to_be_bytes(&self) -> Self::Bytes
fn to_be_bytes(&self) -> Self::Bytes
Encodes integer as bytes in big-endian byte order
Sourcefn to_le_bytes(&self) -> Self::Bytes
fn to_le_bytes(&self) -> Self::Bytes
Encodes integer as bytes in little-endian byte order
Sourcefn from_be_bytes_exact(bytes: &Self::Bytes) -> Option<Self>
fn from_be_bytes_exact(bytes: &Self::Bytes) -> Option<Self>
Decodes integer encoded as bytes in big-endian bytes order
Returns None
if the bytes don’t correspond to a valid integer.
Sourcefn from_le_bytes_exact(bytes: &Self::Bytes) -> Option<Self>
fn from_le_bytes_exact(bytes: &Self::Bytes) -> Option<Self>
Decodes integer encoded as bytes in little-endian bytes order
Returns None
if the bytes don’t correspond to a valid integer.
Sourcefn from_be_bytes_mod_order(bytes: &[u8]) -> Self
fn from_be_bytes_mod_order(bytes: &[u8]) -> Self
Interprets bytes
as big-endian encoding of an integer. Returns integer mod curve (prime) order.
Sourcefn from_le_bytes_mod_order(bytes: &[u8]) -> Self
fn from_le_bytes_mod_order(bytes: &[u8]) -> Self
Interprets bytes
as little-endian encoding of an integer. Returns integer mod curve (prime) order.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.