pub trait IntoEndian<const N: usize> {
// Required methods
fn from_be_bytes<T>(bytes: T) -> Self
where T: AsRef<[u8]>;
fn from_le_bytes<T>(bytes: T) -> Self
where T: AsRef<[u8]>;
fn to_le_bytes(self) -> [u8; N];
fn to_be_bytes(self) -> [u8; N];
}
Expand description
Extension trait for fixed size numbers to allow conversion to/from endian representations.
Required Methods§
Sourcefn from_be_bytes<T>(bytes: T) -> Self
fn from_be_bytes<T>(bytes: T) -> Self
Create instance from Big Endian bytes. Should panic if size is more than N
.
Sourcefn from_le_bytes<T>(bytes: T) -> Self
fn from_le_bytes<T>(bytes: T) -> Self
Create instance from Little Endian bytes. Should panic if size is more than N
.
Sourcefn to_le_bytes(self) -> [u8; N]
fn to_le_bytes(self) -> [u8; N]
Convert instance to Little Endian bytes.
Sourcefn to_be_bytes(self) -> [u8; N]
fn to_be_bytes(self) -> [u8; N]
Convert instance to Big 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.