Struct bitstream::BitWriter
[−]
[src]
pub struct BitWriter<W> where
W: Write, { /* fields omitted */ }
BitWriter is a writer for single bit values
Bits will be grouped to a single byte before writing to the inner writer. The first Bit will be the most significant bit of the byte.
When dropping this writer, any remaining bits will be written as well as an additional byte containing how many bits are significant in the last data byte. This means you can write any number of bits, they do not need to align to multiples of 8.
Examples
extern crate bitstream; let mut vec = Vec::new(); let mut bit_writer = bitstream::BitWriter::new(vec); assert!(bit_writer.write_bit(true).is_ok()); assert!(bit_writer.write_bit(false).is_ok());
Methods
impl<W> BitWriter<W> where
W: Write,
[src]
W: Write,
fn new(write: W) -> Self
Create a new BitWriter, writing to the inner writer.
fn write_bit(&mut self, bit: bool) -> IOResult<()>
Write a single bit to the inner writer.
Failures
Returns an error if the inner writer returns an error
Trait Implementations
impl<W> Drop for BitWriter<W> where
W: Write,
[src]
W: Write,