pub trait BitCodec<const MSB: bool>: Sized {
// Required methods
fn decode(bytes: &[u8], at_bit: usize) -> Result<(Self, usize), ParseError>;
fn encode<B: Buffer>(
&self,
out: &mut BitWriter<'_, B, MSB>,
) -> Result<(), Overflow>;
}Expand description
A value whose width in bits is read from the wire.
The bit-level VarCodec. A #[var] field in a #[message(bits)] uses one.
Required Methods§
Sourcefn decode(bytes: &[u8], at_bit: usize) -> Result<(Self, usize), ParseError>
fn decode(bytes: &[u8], at_bit: usize) -> Result<(Self, usize), ParseError>
Decode from bit at_bit of bytes. Returns the value and the bits consumed.
A successful decode must consume at least one bit.
§Errors
ParseError::Short if the bytes end inside the value, ParseError::Malformed if the
value is too wide for Self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".