pub trait Encoding: Sized {
type Repr: AsRef<[u8]> + AsMut<[u8]> + Copy + Clone + Sized;
const BIT_SIZE: usize;
const BYTE_SIZE: usize;
// Required methods
fn from_be_bytes(bytes: Self::Repr) -> Self;
fn from_le_bytes(bytes: Self::Repr) -> Self;
fn to_be_bytes(&self) -> Self::Repr;
fn to_le_bytes(&self) -> Self::Repr;
}
Expand description
Encoding support.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn from_be_bytes(bytes: Self::Repr) -> Self
fn from_be_bytes(bytes: Self::Repr) -> Self
Decode from big endian bytes.
Sourcefn from_le_bytes(bytes: Self::Repr) -> Self
fn from_le_bytes(bytes: Self::Repr) -> Self
Decode from little endian bytes.
Sourcefn to_be_bytes(&self) -> Self::Repr
fn to_be_bytes(&self) -> Self::Repr
Encode to big endian bytes.
Sourcefn to_le_bytes(&self) -> Self::Repr
fn to_le_bytes(&self) -> Self::Repr
Encode to little endian bytes.
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.