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

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]

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

let r = try!(File::open("somefile"));
let mut br: BitReader<_,MSB> = BitReader::new(r);

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

Examples

let is_one = try!(br.read_bit());

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

Examples

let byte = try!(br.read_byte());

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

let num = try!(br.read_bits(5));

Gets a reference to the underlying stream.