feat(cli): move gzip result classification to Rust
The gzip codec loop already returns distinct status values, but the C wrapper still owned the status branch that selected the CLI failure path. That kept a format-result policy in the implementation-bearing C file even though the loop itself is Rust. Add a Rust diagnostic mapping for success, initialization, deflate, finish, end, invalid projection, and unknown statuses. C now branches on the Rust classification while retaining zlib result values, EXM_THROW codes, and exact diagnostic strings. This keeps the ABI and observable behavior unchanged and leaves unrelated source-exclusion and zstd classification seams untouched. Test Plan: - Nightly rustfmt check on fileio_asyncio.rs -- passed. - Targeted git diff checks -- passed. - Capped GCC syntax-only compile of fileio.c with codec defines -- passed. - Focused Rust mapping tests were added; Cargo/tests were not run per the task's OOM constraint.
This commit is contained in:
@@ -994,6 +994,29 @@ pub const FIO_RUST_GZIP_FINISH_ERROR: c_int = 3;
|
||||
pub const FIO_RUST_GZIP_END_ERROR: c_int = 4;
|
||||
pub const FIO_RUST_GZIP_INVALID_PROJECTION: c_int = 5;
|
||||
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_OK: c_int = 0;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_INIT_ERROR: c_int = 1;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_DEFLATE_ERROR: c_int = 2;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_FINISH_ERROR: c_int = 3;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_END_ERROR: c_int = 4;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_INVALID_PROJECTION: c_int = 5;
|
||||
pub const FIO_RUST_GZIP_DIAGNOSTIC_UNKNOWN: c_int = 6;
|
||||
|
||||
/// Classifies gzip compression results while leaving zlib error values and
|
||||
/// the CLI exception text in the C callback.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn FIO_rust_gzipCompressionDiagnostic(status: c_int) -> c_int {
|
||||
match status {
|
||||
FIO_RUST_GZIP_OK => FIO_RUST_GZIP_DIAGNOSTIC_OK,
|
||||
FIO_RUST_GZIP_INIT_ERROR => FIO_RUST_GZIP_DIAGNOSTIC_INIT_ERROR,
|
||||
FIO_RUST_GZIP_DEFLATE_ERROR => FIO_RUST_GZIP_DIAGNOSTIC_DEFLATE_ERROR,
|
||||
FIO_RUST_GZIP_FINISH_ERROR => FIO_RUST_GZIP_DIAGNOSTIC_FINISH_ERROR,
|
||||
FIO_RUST_GZIP_END_ERROR => FIO_RUST_GZIP_DIAGNOSTIC_END_ERROR,
|
||||
FIO_RUST_GZIP_INVALID_PROJECTION => FIO_RUST_GZIP_DIAGNOSTIC_INVALID_PROJECTION,
|
||||
_ => FIO_RUST_GZIP_DIAGNOSTIC_UNKNOWN,
|
||||
}
|
||||
}
|
||||
|
||||
const FIO_RUST_GZIP_Z_OK: c_int = 0;
|
||||
const FIO_RUST_GZIP_Z_STREAM_END: c_int = 1;
|
||||
const FIO_RUST_GZIP_Z_BUF_ERROR: c_int = -5;
|
||||
@@ -5271,6 +5294,39 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gzip_compression_status_diagnostic_preserves_cli_mapping() {
|
||||
for (status, diagnostic) in [
|
||||
(FIO_RUST_GZIP_OK, FIO_RUST_GZIP_DIAGNOSTIC_OK),
|
||||
(
|
||||
FIO_RUST_GZIP_INIT_ERROR,
|
||||
FIO_RUST_GZIP_DIAGNOSTIC_INIT_ERROR,
|
||||
),
|
||||
(
|
||||
FIO_RUST_GZIP_DEFLATE_ERROR,
|
||||
FIO_RUST_GZIP_DIAGNOSTIC_DEFLATE_ERROR,
|
||||
),
|
||||
(
|
||||
FIO_RUST_GZIP_FINISH_ERROR,
|
||||
FIO_RUST_GZIP_DIAGNOSTIC_FINISH_ERROR,
|
||||
),
|
||||
(FIO_RUST_GZIP_END_ERROR, FIO_RUST_GZIP_DIAGNOSTIC_END_ERROR),
|
||||
(
|
||||
FIO_RUST_GZIP_INVALID_PROJECTION,
|
||||
FIO_RUST_GZIP_DIAGNOSTIC_INVALID_PROJECTION,
|
||||
),
|
||||
] {
|
||||
assert_eq!(FIO_rust_gzipCompressionDiagnostic(status), diagnostic);
|
||||
}
|
||||
|
||||
for status in [-1, 99] {
|
||||
assert_eq!(
|
||||
FIO_rust_gzipCompressionDiagnostic(status),
|
||||
FIO_RUST_GZIP_DIAGNOSTIC_UNKNOWN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lzma_compression_status_diagnostic_preserves_cli_mapping() {
|
||||
for (status, diagnostic) in [
|
||||
|
||||
Reference in New Issue
Block a user