Struct bit_buffers::bit_writer::BitWriter
source · [−]pub struct BitWriter { /* private fields */ }
Expand description
A BitWriter holds a buffer used to store the individual bits being written to it from the user.
Implementations
sourceimpl BitWriter
impl BitWriter
sourcepub fn new() -> BitWriter
pub fn new() -> BitWriter
Returns a new instance of the BitWriter struct with an empty buffer.
Examples
use bit_buffers::BitWriter;
let _bit_writer = BitWriter::new();
sourcepub fn flush_to_file(&mut self, file_name: &str)
pub fn flush_to_file(&mut self, file_name: &str)
Writes the number of bits stored in this BitWriter, followed by the actual bit data stored in this BitWriter out to the specified file, and then clears all data out of this BitWriter so it can be used for more writing.
Arguments
file_name
(&str) - A string slice that holds the name of the file
Panics
Panics if the number of elements in the vector overflows a usize.
Examples
use bit_buffers::BitWriter;
let mut bit_writer = BitWriter::new();
bit_writer.write_bit(1);
bit_writer.write_bit(0);
bit_writer.write_bit(1);
bit_writer.write_bit(1);
bit_writer.flush_to_file("my_bit_file.bit");
sourcepub fn write_bit(&mut self, bit: u8)
pub fn write_bit(&mut self, bit: u8)
Writes the given value as a bit to this BitReader.
Arguments
bit
(u8) - The bit (0 or 1) to write to this BitWriter Testing has not yet been done with values other than 0 or 1.
Examples
use bit_buffers::BitWriter;
let mut bit_writer = BitWriter::new();
bit_writer.write_bit(1);
bit_writer.write_bit(0);
bit_writer.write_bit(1);
bit_writer.write_bit(1);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BitWriter
impl Send for BitWriter
impl Sync for BitWriter
impl Unpin for BitWriter
impl UnwindSafe for BitWriter
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