Trait BitCodec

Source
pub trait BitCodec: BitDecode + BitEncode {
    // Provided methods
    fn decode_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 { ... }
}
Expand description

A trait with helper functions for simple codecs

Provided Methods§

Source

fn decode_bytes<E>(bytes: &[u8], byte_order: E) -> Result<Self>
where E: Endianness,

Parses a new value from its raw byte representation without context.

Source

fn encode_bytes<E>(&self, byte_order: E) -> Result<Vec<u8>>
where E: Endianness,

Gets the raw bytes of this type without context.

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.

Implementors§

Source§

impl<T> BitCodec for T
where T: BitDecode + BitEncode,