feat(compress): return frame progression from Rust
Complete the single-thread branch of ZSTD_getFrameProgression behind a narrow scalar ABI boundary. C still owns the public entry point, buffered input extraction, assertions, and the multithreaded dispatch; Rust now owns the six-field single-thread result construction. The Rust #[repr(C)] result uses wrapping u64 conversion for consumed input plus buffered size, mirrors produced into flushed, and zeros the MT-only fields. This replaces the earlier ingested-only helper so the ABI no longer splits one result across duplicate C and Rust construction paths. The unit tests now cover the complete result and its u64 wrapping behavior. Test Plan: - All three requested compression clippy commands passed before and after `cargo +nightly fmt --manifest-path rust/Cargo.toml`. - `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression` -- 327 passed. - `make -B -C lib -j2 lib` -- passed. - `make -C tests test-rust-lib-smoke` -- passed. - `tests/fuzzer -s4560 -t56 -i57 -v` -- passed. - `make -C tests -j2 test-zstream` -- passed: 84 named, 5,330, and 9,772 randomized cases. - `git diff --check` and `git diff --cached --check` -- passed. The zstream build retains the pre-existing warning at `tests/zstreamtest.c:1899` about an unterminated initializer string.
This commit is contained in:
@@ -48,7 +48,9 @@ int ZSTD_rust_updateFrameProgression(unsigned long long* consumedSrcSize,
|
||||
unsigned long long pledgedSrcSizePlusOne,
|
||||
size_t srcSize, size_t cSize,
|
||||
size_t fhSize);
|
||||
U64 ZSTD_rust_frameProgressionIngested(U64 consumedSrcSize, size_t buffered);
|
||||
ZSTD_frameProgression ZSTD_rust_frameProgression(U64 consumedSrcSize,
|
||||
size_t buffered,
|
||||
U64 producedCSize);
|
||||
size_t ZSTD_rust_resetCCtxForSimpleCompression(void* cctx);
|
||||
size_t ZSTD_rust_prepareCCtxForSimpleCompression(void* cctx,
|
||||
size_t srcSize,
|
||||
@@ -1436,19 +1438,14 @@ ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx)
|
||||
return ZSTDMT_getFrameProgression(cctx->mtctx);
|
||||
}
|
||||
#endif
|
||||
{ ZSTD_frameProgression fp;
|
||||
{
|
||||
size_t const buffered = (cctx->inBuff == NULL) ? 0 :
|
||||
cctx->inBuffPos - cctx->inToCompress;
|
||||
if (buffered) assert(cctx->inBuffPos >= cctx->inToCompress);
|
||||
assert(buffered <= ZSTD_BLOCKSIZE_MAX);
|
||||
fp.ingested = ZSTD_rust_frameProgressionIngested(cctx->consumedSrcSize, buffered);
|
||||
fp.consumed = cctx->consumedSrcSize;
|
||||
fp.produced = cctx->producedCSize;
|
||||
fp.flushed = cctx->producedCSize; /* simplified; some data might still be left within streaming output buffer */
|
||||
fp.currentJobID = 0;
|
||||
fp.nbActiveWorkers = 0;
|
||||
return fp;
|
||||
} }
|
||||
return ZSTD_rust_frameProgression(cctx->consumedSrcSize, buffered,
|
||||
cctx->producedCSize);
|
||||
} }
|
||||
|
||||
/*! ZSTD_toFlushNow()
|
||||
* Only useful for multithreading scenarios currently (nbWorkers >= 1).
|
||||
|
||||
Reference in New Issue
Block a user