feat(compress): move usingCDict wrapper policy into Rust
Move the public ZSTD_compress_usingCDict frame-policy construction and begin-then-end sequencing behind a Rust-owned boundary. Keep the existing C CDict parameter selection, private context initialization, and end-of-frame operations behind narrow callbacks, while preserving the dictionary error short-circuit and hardcoded frame flags. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --release compress_using_cdict -- --nocapture - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --release - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --release --all-targets -- -D warnings - ulimit -v 41943040; make -B -C programs -j1 zstd - ulimit -v 41943040; make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
This commit is contained in:
@@ -1341,6 +1341,32 @@ typedef char ZSTD_rust_compress_begin_using_cdict_state_layout[
|
||||
&& sizeof(ZSTD_rust_compressBeginUsingCDictState)
|
||||
== 12 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef size_t (*ZSTD_rust_compressUsingCDictBegin_f)(
|
||||
void* context, const void* cdict,
|
||||
const ZSTD_frameParameters* fParams, U64 pledgedSrcSize);
|
||||
typedef size_t (*ZSTD_rust_compressUsingCDictEnd_f)(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
const void* cdict;
|
||||
ZSTD_rust_compressUsingCDictBegin_f begin;
|
||||
ZSTD_rust_compressUsingCDictEnd_f end;
|
||||
} ZSTD_rust_compressUsingCDictState;
|
||||
size_t ZSTD_rust_compressUsingCDict(
|
||||
const ZSTD_rust_compressUsingCDictState* state,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize);
|
||||
typedef char ZSTD_rust_compress_using_cdict_state_layout[
|
||||
(offsetof(ZSTD_rust_compressUsingCDictState, callbackContext) == 0
|
||||
&& offsetof(ZSTD_rust_compressUsingCDictState, cdict)
|
||||
== sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressUsingCDictState, begin)
|
||||
== 2 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressUsingCDictState, end)
|
||||
== 3 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_compressUsingCDictState) == 4 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef struct {
|
||||
const ZSTD_compressionParameters* cParams;
|
||||
const unsigned* dictID;
|
||||
@@ -5507,6 +5533,23 @@ static size_t ZSTD_compress_usingCDict_internal(ZSTD_CCtx* cctx,
|
||||
return ZSTD_compressEnd_public(cctx, dst, dstCapacity, src, srcSize);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_compressUsingCDict_begin(
|
||||
void* context, const void* cdict,
|
||||
const ZSTD_frameParameters* fParams, U64 pledgedSrcSize)
|
||||
{
|
||||
return ZSTD_compressBegin_usingCDict_internal(
|
||||
(ZSTD_CCtx*)context, (const ZSTD_CDict*)cdict,
|
||||
*fParams, pledgedSrcSize);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_compressUsingCDict_end(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
return ZSTD_compressEnd_public(
|
||||
(ZSTD_CCtx*)context, dst, dstCapacity, src, srcSize);
|
||||
}
|
||||
|
||||
/*! ZSTD_compress_usingCDict_advanced():
|
||||
* This function is DEPRECATED.
|
||||
*/
|
||||
@@ -5528,8 +5571,13 @@ size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
|
||||
const void* src, size_t srcSize,
|
||||
const ZSTD_CDict* cdict)
|
||||
{
|
||||
ZSTD_frameParameters const fParams = { 1 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
|
||||
return ZSTD_compress_usingCDict_internal(cctx, dst, dstCapacity, src, srcSize, cdict, fParams);
|
||||
ZSTD_rust_compressUsingCDictState state;
|
||||
state.callbackContext = cctx;
|
||||
state.cdict = cdict;
|
||||
state.begin = ZSTD_rust_compressUsingCDict_begin;
|
||||
state.end = ZSTD_rust_compressUsingCDict_end;
|
||||
return ZSTD_rust_compressUsingCDict(
|
||||
&state, dst, dstCapacity, src, srcSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user