Struct huffman_coding::HuffmanWriter [] [src]

pub struct HuffmanWriter<W> where
    W: Write
{ /* fields omitted */ }

HuffmanWriter is a Write implementation that writes encoded words to the inner writer.

Examples

extern crate huffman_coding;
let pseudo_data = vec![0, 0, 1, 2, 2];
let tree = huffman_coding::HuffmanTree::from_data(&pseudo_data[..]);

let mut output = Vec::new();
{
    use std::io::Write;
    let mut writer = huffman_coding::HuffmanWriter::new(&mut output, &tree);
    assert!(writer.write(&[2, 2, 0, 0, 1]).is_ok());
}
assert_eq!(&output[..], [43, 8]);

Methods

impl<W> HuffmanWriter<W> where
    W: Write
[src]

Construct a new HuffmanWriter using the provided HuffmanTree

Trait Implementations

impl<W> Write for HuffmanWriter<W> where
    W: Write
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more