lzw/lib.rs
1//! # LZW decoder and encoder
2//!
3//! This crates provides a `LzwEncoder` and `LzwDecoder`. The code words are written from
4//! and to bit streams where it is possible to write either the most or least significant
5//! bit first. The maximum possible code size is 16 bits. Both types rely on RAII to
6//! produced correct results.
7//!
8//! The de- and encoder expect the LZW stream to start with a clear code and end with an
9//! end code which are defined as follows:
10//!
11//! * `CLEAR_CODE == 1 << min_code_size`
12//! * `END_CODE == CLEAR_CODE + 1`
13//!
14//! Examplary use of the encoder:
15//!
16//! use lzw::{LsbWriter, Encoder};
17//! let size = 8;
18//! let data = b"TOBEORNOTTOBEORTOBEORNOT";
19//! let mut compressed = vec![];
20//! {
21//! let mut enc = Encoder::new(LsbWriter::new(&mut compressed), size).unwrap();
22//! enc.encode_bytes(data).unwrap();
23//! }
24
25mod lzw;
26mod bitstream;
27
28pub use lzw::{
29 Decoder,
30 DecoderEarlyChange,
31 Encoder,
32 encode
33};
34
35pub use bitstream::{
36 BitReader,
37 BitWriter,
38 LsbReader,
39 LsbWriter,
40 MsbReader,
41 MsbWriter,
42 Bits
43};