refactor(cli): move decompression diagnostic mapping to Rust
Move the status-to-diagnostic policy for decompression failures into the Rust fileio layer. C retains the user-facing strings and callback display logic, while Rust returns a stable diagnostic classification across the ABI and leaves silent statuses silent. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo +nightly fmt --manifest-path rust/Cargo.toml -- --check - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --all-targets (775 passed) - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/cli/Cargo.toml --all-targets (179 passed) - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test (all tests completed successfully)
This commit is contained in:
+17
-7
@@ -434,6 +434,15 @@ enum {
|
||||
FIO_RUST_DECOMPRESS_PASS_THROUGH_ERROR = 9,
|
||||
FIO_RUST_DECOMPRESS_ZSTD_UNSUPPORTED = 10
|
||||
};
|
||||
enum {
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_NONE = 0,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_EMPTY_INPUT = 1,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_SHORT_INPUT = 2,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_GZIP_UNSUPPORTED = 3,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_LZMA_UNSUPPORTED = 4,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_LZ4_UNSUPPORTED = 5,
|
||||
FIO_RUST_DECOMPRESS_DIAGNOSTIC_UNSUPPORTED_FORMAT = 6
|
||||
};
|
||||
typedef int (*FIO_rust_decompress_frame_fn)(void* opaque,
|
||||
const char* srcFileName,
|
||||
U64 alreadyDecoded,
|
||||
@@ -466,6 +475,7 @@ int FIO_rust_finishDecompressFrames(int status,
|
||||
const char* srcFileName,
|
||||
U64 decodedSize,
|
||||
const FIO_rust_decompress_callbacks_t* callbacks);
|
||||
int FIO_rust_decompressStatusDiagnostic(int status);
|
||||
|
||||
typedef void (*FIO_rust_decompress_read_fill_fn)(
|
||||
void* opaque, size_t requested, const unsigned char** buffer, size_t* loaded);
|
||||
@@ -4122,23 +4132,23 @@ static void FIO_rust_decompressStatusCallback(void* opaque,
|
||||
const char* srcFileName)
|
||||
{
|
||||
(void)opaque;
|
||||
switch (status) {
|
||||
case FIO_RUST_DECOMPRESS_EMPTY_INPUT:
|
||||
switch (FIO_rust_decompressStatusDiagnostic(status)) {
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_EMPTY_INPUT:
|
||||
DISPLAYLEVEL(1, "zstd: %s: unexpected end of file \n", srcFileName);
|
||||
break;
|
||||
case FIO_RUST_DECOMPRESS_SHORT_INPUT:
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_SHORT_INPUT:
|
||||
DISPLAYLEVEL(1, "zstd: %s: unknown header \n", srcFileName);
|
||||
break;
|
||||
case FIO_RUST_DECOMPRESS_GZIP_UNSUPPORTED:
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_GZIP_UNSUPPORTED:
|
||||
DISPLAYLEVEL(1, "zstd: %s: gzip file cannot be uncompressed (zstd compiled without HAVE_ZLIB) -- ignored \n", srcFileName);
|
||||
break;
|
||||
case FIO_RUST_DECOMPRESS_LZMA_UNSUPPORTED:
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_LZMA_UNSUPPORTED:
|
||||
DISPLAYLEVEL(1, "zstd: %s: xz/lzma file cannot be uncompressed (zstd compiled without HAVE_LZMA) -- ignored \n", srcFileName);
|
||||
break;
|
||||
case FIO_RUST_DECOMPRESS_LZ4_UNSUPPORTED:
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_LZ4_UNSUPPORTED:
|
||||
DISPLAYLEVEL(1, "zstd: %s: lz4 file cannot be uncompressed (zstd compiled without HAVE_LZ4) -- ignored \n", srcFileName);
|
||||
break;
|
||||
case FIO_RUST_DECOMPRESS_UNSUPPORTED_FORMAT:
|
||||
case FIO_RUST_DECOMPRESS_DIAGNOSTIC_UNSUPPORTED_FORMAT:
|
||||
DISPLAYLEVEL(1, "zstd: %s: unsupported format \n", srcFileName);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user