Struct bit_buffers::bit_reader::BitReader
source · [−]pub struct BitReader { /* private fields */ }
Expand description
A BitReader holds a buffer used to store the individual bits read in from a file.
Implementations
sourceimpl BitReader
impl BitReader
sourcepub fn new() -> BitReader
pub fn new() -> BitReader
Returns a new instance of the BitReader struct with an empty buffer.
Examples
use bit_buffers::BitReader;
let _bit_reader = BitReader::new();
sourcepub fn load_from_file(&mut self, file_name: &str) -> Result<()>
pub fn load_from_file(&mut self, file_name: &str) -> Result<()>
Loads the bits stored in a file into this BitReader.
Arguments
file_name
(&str) - A string slice that holds the name of the file
Errors
This function will return an error if file_name
does not already
exist. Other errors may be returned according to OpenOptions::open
.
It will also return an error if it encounters while reading an error of
a kind other than io::ErrorKind::Interrupted
.
Examples
use bit_buffers::BitReader;
let mut bit_reader = BitReader::new();
bit_reader.load_from_file("my_bit_file.bit");
sourcepub fn read_bit(&mut self) -> Option<u8>
pub fn read_bit(&mut self) -> Option<u8>
Reads the current bit being referenced by this BitReader.
Examples
use bit_buffers::BitReader;
let mut bit_reader = BitReader::new();
bit_reader.load_from_file("my_bit_file.bit");
let bit_option = bit_reader.read_bit();
if let Some(bit) = bit_option {
println!("Read in a {} bit from bit_reader", bit);
}
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BitReader
impl Send for BitReader
impl Sync for BitReader
impl Unpin for BitReader
impl UnwindSafe for BitReader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more