Crate lzw[−][src]
Expand description
LZW decoder and encoder
This crates provides a LzwEncoder
and LzwDecoder
. The code words are written from
and to bit streams where it is possible to write either the most or least significant
bit first. The maximum possible code size is 16 bits. Both types rely on RAII to
produced correct results.
The de- and encoder expect the LZW stream to start with a clear code and end with an end code which are defined as follows:
CLEAR_CODE == 1 << min_code_size
END_CODE == CLEAR_CODE + 1
Examplary use of the encoder:
use lzw::{LsbWriter, Encoder}; let size = 8; let data = b"TOBEORNOTTOBEORTOBEORNOT"; let mut compressed = vec![]; { let mut enc = Encoder::new(LsbWriter::new(&mut compressed), size).unwrap(); enc.encode_bytes(data).unwrap(); }
Structs
Decoder | Decoder for a LZW compressed stream (this algorithm is used for GIF files). |
DecoderEarlyChange | Decoder for a LZW compressed stream using an “early change” algorithm (used in TIFF files). |
Encoder | LZW encoder using the algorithm of GIF files. |
LsbReader | Reads bits from a byte stream, LSB first. |
LsbWriter | Writes bits to a byte stream, LSB first. |
MsbReader | Reads bits from a byte stream, MSB first. |
MsbWriter | Writes bits to a byte stream, MSB first. |
Enums
Bits | Containes either the consumed bytes and reconstructed bits or only the consumed bytes if the supplied buffer was not bit enough |
Traits
BitReader | A bit reader. |
BitWriter | A bit writer. |
Functions
encode | Convenience function that reads and compresses all bytes from |