Trait FromBits

Source
pub trait FromBits {
    type Symbol;

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

A trait for building a final value from individual bits

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

Required Associated Types§

Source

type Symbol

Our returned symbol type

Required Methods§

Source

fn from_bits<F, E>(next: F) -> Result<Self::Symbol, E>
where F: FnMut() -> Result<bool, E>,

Given a fallable bit generator, return our output type

§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> FromBits for LimitedUnary<STOP_BIT, MAXIMUM>