Struct bit_manager::BitReader
[−]
[src]
pub struct BitReader<T: Read> { /* fields omitted */ }
A wrapper for any type implementing io::Read
that allows the reading of individual bits
Example
use bit_manager::{BitReader, BitRead}; let mut reader = BitReader::new([0b01101110u8, 0b10100000u8].as_ref()); assert_eq!(reader.read_bit()?, false); assert_eq!(reader.read_bit()?, true); assert_eq!(reader.read_bit()?, true); assert_eq!(reader.read_byte()?, 0b01110101);
Methods
impl<T: Read> BitReader<T>
[src]
fn new(reader: T) -> BitReader<T>
[src]
Creates a new bit reader with the given reader. Uses Precision::Byte
by default.
fn new_with_precision(reader: T, precision: Precision) -> BitReader<T>
[src]
Creates a new bit reader with the given reader and precision.
fn is_aligned(&self) -> bool
[src]
Returns true
if the internal buffer is aligned to a byte.
fn align(&mut self) -> Result<()>
[src]
Aligns the stream to the next byte.
Trait Implementations
impl<T: Read> BitRead for BitReader<T>
[src]
fn read_bit(&mut self) -> Result<bool>
[src]
Reads a single bit.
fn read_byte(&mut self) -> Result<u8>
[src]
Reads a single byte. Read more
fn read<T: BitStore>(&mut self) -> Result<T>
[src]
Reads a value that implements [BitStore
] using the read_from
function. Read more
fn read_using<T, C>(&mut self, converter: &C) -> Result<T> where
C: BitConvert<T>,
[src]
C: BitConvert<T>,
Reads a value using a converter that implements [BitConvert
] with the read_value_from
function. Read more
fn read_to_buffer<T, B>(&mut self, buffer: B) -> usize where
T: BitStore,
B: AsMut<[T]>,
[src]
T: BitStore,
B: AsMut<[T]>,
Reads values that implement [BitStore
] to a buffer. Returns the number of values read. Read more
fn read_to_buffer_using<T, B, C>(&mut self, buffer: B, converter: &C) -> usize where
B: AsMut<[T]>,
C: BitConvert<T>,
[src]
B: AsMut<[T]>,
C: BitConvert<T>,
Reads values using a converter that implements [BitConvert
] to a buffer. Returns the number of values read. Read more