feat(rust): port frame serialization
Continue the incremental zstd_compress.c migration with its frame serialization leaves: ZSTD_writeFrameHeader(), the public ZSTD_writeSkippableFrame() ABI, and ZSTD_writeLastEmptyBlock() now live in rust/src/zstd_compress_frame.rs. ZSTD_writeFrameHeader() reads five fields out of ZSTD_CCtx_params, whose layout is private to zstd_compress.c and sensitive to build configuration. Rather than mirror that structure in Rust, the C function keeps its original static signature and forwards the scalar fields to ZSTD_rust_writeFrameHeader(), so no parameter-structure layout crosses the language boundary. The other two functions take only pointer/size arguments and are exported directly, replacing their C bodies outright. Behavior differences are limited to hardening in release builds: the Rust leaf clamps a window-size shift that C would leave undefined for a malformed windowLog, and ZSTD_writeSkippableFrame() rejects a srcSize + header overflow instead of comparing against a wrapped sum. Both paths are unreachable through validated callers, so compressed output is byte-identical. Remaining zstd_compress.c work: parameter selection and validation, context lifecycle, block dispatch, dictionary loading, and the streaming state machine. Test plan: - cd rust && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test --all-targets (118 tests, includes new frame header/skippable/last-block reference vectors) - make -C tests fuzzer && ./tests/fuzzer -i1 --no-big-tests - make -C tests test-rust-lib-smoke
This commit is contained in:
@@ -31,6 +31,9 @@ zstd ABI:
|
||||
- `zstd_presplit` chooses split points for full compression blocks.
|
||||
- `zstd_compress_literals` emits raw, RLE, and Huffman literal sections
|
||||
while preserving the compressor's Huffman-table repeat state.
|
||||
- `zstd_compress_frame` serializes frame headers, skippable frames, and the
|
||||
last empty block; it takes scalar frame parameters so the C-owned
|
||||
`ZSTD_CCtx_params` layout never crosses the language boundary.
|
||||
- `zstd_fast` and `zstd_double_fast` implement the single- and two-table
|
||||
fast block match finders, including attached and external dictionary paths.
|
||||
- `zstd_lazy` implements greedy, lazy, lazy2, and binary-tree matching,
|
||||
|
||||
Reference in New Issue
Block a user