Trait bitstream_io::Primitive
source · pub trait Primitive {
type Bytes: AsRef<[u8]> + AsMut<[u8]>;
// Required methods
fn buffer() -> Self::Bytes;
fn to_be_bytes(self) -> Self::Bytes;
fn to_le_bytes(self) -> Self::Bytes;
fn from_be_bytes(bytes: Self::Bytes) -> Self;
fn from_le_bytes(bytes: Self::Bytes) -> Self;
}
Expand description
A trait intended for simple fixed-length primitives (such as ints and floats) which allows them to be read and written to streams of different endiannesses verbatim.
Required Associated Types§
Required Methods§
sourcefn to_be_bytes(self) -> Self::Bytes
fn to_be_bytes(self) -> Self::Bytes
Our value in big-endian bytes
sourcefn to_le_bytes(self) -> Self::Bytes
fn to_le_bytes(self) -> Self::Bytes
Our value in little-endian bytes
sourcefn from_be_bytes(bytes: Self::Bytes) -> Self
fn from_be_bytes(bytes: Self::Bytes) -> Self
Convert big-endian bytes to our value
sourcefn from_le_bytes(bytes: Self::Bytes) -> Self
fn from_le_bytes(bytes: Self::Bytes) -> Self
Convert little-endian bytes to out value
Object Safety§
This trait is not object safe.