feat(rust): port Huffman compression

Move Huffman table construction, table serialization, and one- and
four-stream payload encoding from huf_compress.c into the Rust compatibility
archive.  The declaration-only C shim preserves the existing internal ABI,
so the remaining C compressor can call the migrated implementation unchanged.

The translation keeps CTable layouts, workspace checks, repeat-table
selection, and bitstream output compatible with the original encoder.  This
lets native C consumers exercise the Rust implementation through libzstd.

Test Plan:
- cargo clippy, cargo clippy --benches, and cargo clippy --tests
- cargo +nightly fmt and cargo test --all-targets (88 passed)
- cargo check --no-default-features --features compression
- rebuild and run tests fuzzer, zstreamtest, and invalidDictionaries
- compare tables, headers, and 1X/4X streams with a renamed pristine C build

Refs: rust/README.md component map
This commit is contained in:
2026-07-10 21:54:23 +02:00
parent d784406374
commit 0a6a5f5267
4 changed files with 1552 additions and 1463 deletions
+2
View File
@@ -22,6 +22,8 @@ zstd ABI:
- `fse_decompress` builds FSE decoding tables and decodes FSE streams.
- `fse_compress` normalizes counts, writes FSE headers, builds compression
tables, and encodes FSE streams.
- `huf_compress` builds Huffman compression tables, writes table headers,
and encodes one- and four-stream Huffman payloads.
- `huf_decompress` builds Huffman decoding tables and decodes X1 and X2
Huffman streams.
- Compression primitives