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

Returns a new instance of the BitWriter struct with an empty buffer.

Examples
use bit_buffers::BitWriter;
let _bit_writer = BitWriter::new();

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");

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

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.