packkit/snappy

Snappy raw-block and framed codec.

snappy.raw_decode and snappy.raw_encode operate on the original Snappy block format documented in snappy-format-description. snappy.decode and snappy.encode operate on the streaming framed form (sNaPpY stream identifier and chunked layout). The raw encoder runs a greedy 4-byte hash-chain match-finder and emits literal + copy-1 / copy-2 / copy-4 sequences in the canonical block layout; the framed encoder dispatches each chunk through the raw encoder and picks the smaller of the compressed (0x00) and uncompressed (0x01) chunk types.

Values

pub fn codec() -> codec.Codec

Snappy framed codec smart constructor.

pub fn decode(
  bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)

Decode a framed Snappy stream using the default resource limits.

pub fn decode_with_limits(
  bytes bytes: BitArray,
  limits limits: limit.Limits,
) -> Result(BitArray, error.CodecError)

Decode a framed Snappy stream using explicit resource limits.

pub fn encode(
  bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)

Encode bytes as a framed Snappy stream that stores every chunk in the uncompressed form.

pub fn raw_decode(
  bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)

Decode a single Snappy raw block.

pub fn raw_decode_with_limits(
  bytes bytes: BitArray,
  limits limits: limit.Limits,
) -> Result(BitArray, error.CodecError)

Decode a Snappy raw block using explicit resource limits.

pub fn raw_encode(
  bytes bytes: BitArray,
) -> Result(BitArray, error.CodecError)

Encode bytes as a Snappy raw block. Runs a greedy LZ77 match- finder (4-byte hash table, 16-bit hash) and emits literal + copy-1 / copy-2 / copy-4 sequences in the canonical block layout. Inputs of fewer than 4 bytes — where no copy can fit the 4-byte minimum match — degenerate to a single literal run.

Search Document