[][src]Struct bitbit::reader::BitReader

pub struct BitReader<R: Read, B: Bit> { /* fields omitted */ }

A BitReader gives a way to read single bits from a stream.

Methods

impl<R: Read, B: Bit> BitReader<R, B>[src]

pub fn new(reader: R) -> BitReader<R, B>[src]

Constructs a new BitReader. Requires an implementation of Bit type to determine which end of bytes to read bits from.

Arguments

  • reader - an existing open file or stream (implementing Read).

Examples

This example is not tested
let r = File::open("somefile")?;
let mut br: BitReader<_,MSB> = BitReader::new(r);

pub fn read_bit(&mut self) -> Result<bool>[src]

Reads a single bit from a BitReader. Returns true for a 1 bit, false for a 0 bit.

Examples

This example is not tested
let is_one = br.read_bit()?;

pub fn read_byte(&mut self) -> Result<u8>[src]

Reads 8 bits from a BitReader and returns them as a single byte.

Examples

This example is not tested
let byte = br.read_byte()?;

pub fn read_bits(&mut self, nbits: usize) -> Result<u32>[src]

Read a number of bits from a BitReader and return them in a u32. Will not read more than 32 bits.

Arguments

  • bits - number of bits to read

Examples

This example is not tested
let num = br.read_bits(5)?;

pub fn get_ref(&mut self) -> &R[src]

Gets a reference to the underlying stream.

Auto Trait Implementations

impl<R, B> !Send for BitReader<R, B>

impl<R, B> !Sync for BitReader<R, B>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.