refactor(compress): expose pure parameter policy leaves from Rust

The compression-parameter check, clamp, and cycle-log helpers were still
translation-unit C bodies that only forwarded value arguments to Rust. That
left redundant C ownership and made the direct Rust ABI names differ from the
public or internal C symbols used by callers. Export the existing C names from
the Rust parameter module and remove the forwarding bodies. Crate-local aliases
retain the old Rust-side names for existing Rust callers; all private context,
configuration, assertion, and stateful adapters remain on the C side.

Test Plan:
- `cc -fsyntax-only -Ilib -Icommon lib/compress/zstd_compress.c` -- passed.
- `cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- passed.
- `git diff --check` and `git diff --cached --check` -- passed.
- Heavy cargo, make, and test commands were intentionally not run per scope.
This commit is contained in:
2026-07-20 12:22:25 +02:00
parent d2a43b5080
commit 6d9b3d24b6
2 changed files with 11 additions and 31 deletions
+1 -27
View File
@@ -1924,12 +1924,10 @@ void ZSTD_rust_setBufferExpectations(
* scalar inputs. The ZSTD_CParamMode_e and ZSTD_ParamSwitch_e enums are
* passed as int; the Rust side mirrors their values. */
ZSTD_bounds ZSTD_rust_params_getBounds(int param);
size_t ZSTD_rust_params_checkCParams(ZSTD_compressionParameters cParams);
void ZSTD_rust_params_assertEqualCParams(ZSTD_compressionParameters cParams1,
ZSTD_compressionParameters cParams2);
ZSTD_compressionParameters
ZSTD_rust_params_clampCParams(ZSTD_compressionParameters cParams);
U32 ZSTD_rust_params_cycleLog(U32 hashLog, int strategy);
ZSTD_clampCParams(ZSTD_compressionParameters cParams);
ZSTD_compressionParameters
ZSTD_rust_params_selectCParams(int compressionLevel, U64 srcSizeHint,
size_t dictSize, int mode);
@@ -3849,30 +3847,6 @@ size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset)
}
/** ZSTD_checkCParams() :
control CParam values remain within authorized range.
@return : 0, or an error code if one value is beyond authorized range */
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
{
return ZSTD_rust_params_checkCParams(cParams);
}
/** ZSTD_clampCParams() :
* make CParam values within valid range.
* @return : valid CParams */
static ZSTD_compressionParameters
ZSTD_clampCParams(ZSTD_compressionParameters cParams)
{
return ZSTD_rust_params_clampCParams(cParams);
}
/** ZSTD_cycleLog() :
* condition for correct operation : hashLog > 1 */
U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)
{
return ZSTD_rust_params_cycleLog(hashLog, (int)strat);
}
U32 ZSTD_getCParamsExclusionMask(void);
/** ZSTD_adjustCParams_internal() :