Skip to main content

BitRead

Trait BitRead 

Source
pub trait BitRead: Sized {
    // Required method
    fn read_bit(&mut self) -> Result<bool>;

    // Provided methods
    fn read_byte(&mut self) -> Result<u8> { ... }
    fn read<T: BitStore>(&mut self) -> Result<T> { ... }
    fn read_using<T, C>(&mut self, converter: &C) -> Result<T>
       where C: BitConvert<T> { ... }
    fn read_to_buffer<T, B>(&mut self, buffer: B) -> usize
       where T: BitStore,
             B: AsMut<[T]> { ... }
    fn read_to_buffer_using<T, B, C>(
        &mut self,
        buffer: B,
        converter: &C,
    ) -> usize
       where B: AsMut<[T]>,
             C: BitConvert<T> { ... }
}
Expand description

A trait for types that can read bits

Required Methods§

Source

fn read_bit(&mut self) -> Result<bool>

Reads a single bit.

Provided Methods§

Source

fn read_byte(&mut self) -> Result<u8>

Reads a single byte.

Default implementation is unoptimized and should be overridden

Source

fn read<T: BitStore>(&mut self) -> Result<T>

Reads a value that implements BitStore using the read_from function.

Source

fn read_using<T, C>(&mut self, converter: &C) -> Result<T>
where C: BitConvert<T>,

Reads a value using a converter that implements BitConvert with the read_value_from function.

Source

fn read_to_buffer<T, B>(&mut self, buffer: B) -> usize
where T: BitStore, B: AsMut<[T]>,

Reads values that implement BitStore to a buffer. Returns the number of values read.

Source

fn read_to_buffer_using<T, B, C>(&mut self, buffer: B, converter: &C) -> usize
where B: AsMut<[T]>, C: BitConvert<T>,

Reads values using a converter that implements BitConvert to a buffer. Returns the number of values read.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§