refactor(cli): move pass-through selection policy to Rust
Move automatic decompression pass-through selection into a pure Rust scalar policy while preserving explicit preference values, stdout probing, overwrite semantics, assertions, diagnostics, and all C-owned file/resource callbacks. The C fileio boundary now supplies only the policy inputs before constructing the existing callback projection. Test Plan: ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings; cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings; cargo test --manifest-path rust/cli/Cargo.toml --all-targets (188 passed); cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check; make -j1; ./tests/rustLibSmoke; make -j1 -C tests test (all shell tests, large streaming tests, native tester, fuzzer phases, and zstream tester passed).
This commit is contained in:
+7
-8
@@ -471,6 +471,9 @@ int FIO_rust_finishDecompressFrames(int status,
|
||||
U64 decodedSize,
|
||||
const FIO_rust_decompress_callbacks_t* callbacks);
|
||||
int FIO_rust_decompressStatusDiagnostic(int status);
|
||||
int FIO_rust_decompressPassThroughPolicy(int passThrough,
|
||||
int overwrite,
|
||||
int destinationIsStdout);
|
||||
|
||||
typedef void (*FIO_rust_decompress_read_fill_fn)(
|
||||
void* opaque, size_t requested, const unsigned char** buffer, size_t* loaded);
|
||||
@@ -4216,18 +4219,14 @@ static int FIO_decompressFrames(FIO_ctx_t* const fCtx,
|
||||
const char* dstFileName, const char* srcFileName)
|
||||
{
|
||||
U64 filesize = 0;
|
||||
int passThrough = prefs->passThrough;
|
||||
int const passThrough = FIO_rust_decompressPassThroughPolicy(
|
||||
prefs->passThrough,
|
||||
prefs->overwrite,
|
||||
prefs->passThrough == -1 ? !strcmp(dstFileName, stdoutmark) : 0);
|
||||
FIO_rust_decompression_projection_t projection;
|
||||
FIO_rust_decompress_callbacks_t callbacks;
|
||||
int status;
|
||||
|
||||
if (passThrough == -1) {
|
||||
/* If pass-through mode is not explicitly enabled or disabled,
|
||||
* default to the legacy behavior of enabling it if we are writing
|
||||
* to stdout with the overwrite flag enabled.
|
||||
*/
|
||||
passThrough = prefs->overwrite && !strcmp(dstFileName, stdoutmark);
|
||||
}
|
||||
assert(passThrough == 0 || passThrough == 1);
|
||||
|
||||
projection.fCtx = fCtx;
|
||||
|
||||
Reference in New Issue
Block a user