Skip to main content

Module bitstream

Module bitstream 

Source
Expand description

Bit-level stream writers for zstd encoding.

BitWriter — forward bitstream (Huffman literals). BackwardBitWriter — backward bitstream (FSE sequences, FSE weights).

The backward bitstream matches C zstd’s BIT_CStream_t exactly:

  • Bits accumulate LSB-first in a 64-bit register
  • flush_bits() writes full bytes to output (forward/LE)
  • finish() adds sentinel 1-bit, flushes, returns bytes
  • Decoder reads this from the END toward the BEGINNING

Structs§

BackwardBitWriter
Backward bitstream writer matching C zstd’s BIT_CStream_t.
BitWriter
Forward bitstream writer (Huffman literal streams).