packkit/lzw
Unix compress(1) LZW codec — .Z stream encoder and decoder.
The stream begins with the two-byte magic 1F 9D followed by a
flag byte whose low five bits hold the maximum code width
(9..16) and whose top bit toggles block-compress mode. Codes
are packed LSB-first across bytes, the dictionary starts with
the 256 byte literals (plus a clear-table marker when block mode
is on), and each new entry maps the previous code plus the
current character to the next free code. When the dictionary
fills the current width, the encoder pads to the next
width * 8 bit boundary before promoting to the next width or
emitting a clear-table code.
Values
pub fn decode(
bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)
Decode a .Z stream using the shared default Limits.
pub fn decode_with_limits(
bytes bytes: BitArray,
limits limits: limit.Limits,
) -> Result(BitArray, error.CodecError)
Decode a .Z stream using explicit Limits.
pub fn encode(
bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)
Encode bytes as a .Z stream using the default 16-bit
block-mode encoder.
pub fn encode_with_options(
bytes bytes: BitArray,
max_bits max_bits: Int,
block_mode block_mode: Bool,
) -> Result(BitArray, error.CodecError)
Encode bytes as a .Z stream with explicit options.