[−][src]Struct bitbit::reader::BitReader
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
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,