Struct bitstream::BitWriter [] [src]

pub struct BitWriter<W, P> where
    W: Write,
    P: Padding
{ /* 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 according to the padding used. The default padding is NoPadding

Examples

extern crate bitstream;

let 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, NoPadding> where
    W: Write
[src]

Create a new BitWriter with no padding, writing to the inner writer.

impl<W, P> BitWriter<W, P> where
    W: Write,
    P: Padding
[src]

Create a new BitWriter with the given padding

Write a single bit to the inner writer.

Failures

Returns an error if the inner writer returns an error

Trait Implementations

impl<W, P> Drop for BitWriter<W, P> where
    W: Write,
    P: Padding
[src]

A method called when the value goes out of scope. Read more