feat(compress): move sequence copier selection to Rust

ZSTD_selectSequenceCopier combined block-delimiter validation with its
private C function-pointer dispatch. Move only the scalar mode policy behind
a Rust ABI shim, retaining the function-pointer switch and both sequence
transfer implementations in C. Rust preserves the 0..=1 debug validation and
the release fallback to no-block-delimiters for unsupported values.

Test Plan:
- `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression` — 281 passed.
- Required clippy checks for the library, benches, and tests passed before and after `cargo +nightly fmt`.
- `make -B -C lib -j2 lib` and `make -B -C tests test-rust-lib-smoke` — passed.
- `tests/fuzzer -s4560 -t47 -i48 -v` and `tests/fuzzer -s4560 -t56 -i57 -v` — passed.
- `make -C tests -j2 test-zstream` — 84 named, 7,298 standard randomized, and 9,379 new-API randomized cases passed.
- `git diff --check` and `git diff --cached --check` — passed.
This commit is contained in:
2026-07-18 11:08:27 +02:00
parent 21431587fa
commit effef1b8b1
2 changed files with 80 additions and 4 deletions
+6 -4
View File
@@ -356,6 +356,7 @@ size_t ZSTD_rust_blockSizeExplicitDelimiter(const ZSTD_Sequence* inSeqs,
size_t ZSTD_rust_determineBlockSize(int mode, size_t blockSize, size_t remaining,
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
U32 seqIdx);
int ZSTD_rust_selectSequenceCopier(int mode);
size_t ZSTD_rust_loadCEntropy(ZSTD_compressedBlockState_t* bs, void* workspace,
const void* dict, size_t dictSize);
size_t ZSTD_rust_transferSequencesWBlockDelim(
@@ -5164,12 +5165,13 @@ typedef size_t (*ZSTD_SequenceCopier_f)(ZSTD_CCtx* cctx,
static ZSTD_SequenceCopier_f ZSTD_selectSequenceCopier(ZSTD_SequenceFormat_e mode)
{
assert(ZSTD_cParam_withinBounds(ZSTD_c_blockDelimiters, (int)mode));
if (mode == ZSTD_sf_explicitBlockDelimiters) {
switch (ZSTD_rust_selectSequenceCopier((int)mode)) {
case ZSTD_sf_explicitBlockDelimiters:
return ZSTD_transferSequences_wBlockDelim;
case ZSTD_sf_noBlockDelimiters:
default:
return ZSTD_transferSequences_noDelim;
}
assert(mode == ZSTD_sf_noBlockDelimiters);
return ZSTD_transferSequences_noDelim;
}
static size_t determine_blockSize(ZSTD_SequenceFormat_e mode,