Trait ToBits

Source
pub trait ToBits {
    type Symbol;

    // Required method
    fn to_bits<F, E>(value: Self::Symbol, write: F) -> Result<(), E>
       where F: FnMut(bool) -> Result<(), E>;
}
Expand description

For building individual bits from a final value

Though similar to the crate::write::ToBitStream trait, this is intended to generate a stream of bits from short symbols while ToBitStream is meant for writing larger structs to a whole writer. For example, one might have several ToBits implementations in a single program that all write i32 symbols to bits, but implementing ToBitStream multiple times for i32 isn’t possible (or practical).

Required Associated Types§

Source

type Symbol

The type we accept to output

Required Methods§

Source

fn to_bits<F, E>(value: Self::Symbol, write: F) -> Result<(), E>
where F: FnMut(bool) -> Result<(), E>,

Given a value to generate, write out bits as needed.

Outputs nothing if the symbol isn’t defined.

§Errors

Passes along any error from the bit generator

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<const STOP_BIT: u8, const MAXIMUM: u32> ToBits for LimitedUnary<STOP_BIT, MAXIMUM>