pub trait BitCodec:
BitDecode
+ BitEncode
+ Sealed {
// Provided methods
fn decode_bytes<E>(bytes: &[u8], byte_order: E) -> Result<(Self, u64)>
where E: Endianness { ... }
fn decode_all_bytes<E>(bytes: &[u8], byte_order: E) -> Result<Self>
where E: Endianness { ... }
fn encode_bytes<E>(&self, byte_order: E) -> Result<Vec<u8>>
where E: Endianness { ... }
fn encode_bytes_buf<E>(&self, byte_order: E, buf: &mut [u8]) -> Result<u64>
where E: Endianness { ... }
}Expand description
A trait with helper functions for simple codecs.
Provided Methods§
Sourcefn decode_bytes<E>(bytes: &[u8], byte_order: E) -> Result<(Self, u64)>where
E: Endianness,
fn decode_bytes<E>(bytes: &[u8], byte_order: E) -> Result<(Self, u64)>where
E: Endianness,
Parses a new value from its raw byte representation.
Returns a tuple of the parsed value and the number of bits read.
Sourcefn decode_all_bytes<E>(bytes: &[u8], byte_order: E) -> Result<Self>where
E: Endianness,
fn decode_all_bytes<E>(bytes: &[u8], byte_order: E) -> Result<Self>where
E: Endianness,
Parses a new value from its raw byte representation, consuming entire buffer.
Sourcefn encode_bytes<E>(&self, byte_order: E) -> Result<Vec<u8>>where
E: Endianness,
Available on crate feature alloc only.
fn encode_bytes<E>(&self, byte_order: E) -> Result<Vec<u8>>where
E: Endianness,
alloc only.Gets the raw bytes of this type.
Sourcefn encode_bytes_buf<E>(&self, byte_order: E, buf: &mut [u8]) -> Result<u64>where
E: Endianness,
fn encode_bytes_buf<E>(&self, byte_order: E, buf: &mut [u8]) -> Result<u64>where
E: Endianness,
Fills the buffer with the raw bytes of this type.
Returns the number of bytes written.
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.