Problem
FrameCompressor ties the content-checksum (the 4-byte XXH64 frame trailer) to the hash cargo feature with no runtime opt-out:
// src/encoding/frame_compressor.rs (~L866)
let header = FrameHeader {
...
content_checksum: cfg!(feature = "hash"),
...
};
So with hash enabled, every emitted frame carries a content checksum: the encoder XXH64-hashes the full uncompressed input and appends 4 bytes. There is no FrameCompressor method to disable it per-instance/per-frame, and compress_to_vec / compress expose no knob either.
For a consumer that wants the checksum only as an opt-in diagnostic on selected frames (and a zero-overhead default elsewhere), this is all-or-nothing: enabling the feature forces the hash + 4 bytes onto the hot path globally.
Request
Add an opt-in setter so content-checksum emission is per-instance, defaulting to the current cfg!(feature = "hash") behaviour for backwards compatibility:
impl FrameCompressor {
/// Enable/disable the 4-byte content-checksum trailer for
/// subsequent frames. Defaults to `cfg!(feature = "hash")`.
#[cfg(feature = "hash")]
pub fn with_content_checksum(&mut self, enabled: bool) -> &mut Self { ... }
}
(Name/shape up to you — set_content_checksum, a builder arg, etc. The need is a runtime toggle, not a new compile-time feature.)
Decode side (related)
On the read side, FrameDecoder reads the trailer (get_checksum_from_data()) and can compute the running digest (get_calculated_checksum(), behind hash), but decode_all / decode_all_to_vec do not automatically compare calculated vs stored — there is no ChecksumMismatch error variant. A consumer that wants the checksum to actually gate decode currently has to call both accessors and compare by hand after a full decode.
Would be useful (optionally, behind hash / a decoder flag) to have the decode path verify the trailer and surface a typed FrameDecoderError::ContentChecksumMismatch { expected, found } so the checksum can be used as an integrity gate without manual post-hoc comparison.
Use case
coordinode-lsm-tree wants content-checksum as an opt-in encoder-correctness diagnostic (catch decompress(compress(x)) != x from an encoder bug) on a subset of writes, with the mandatory write path paying zero extra cost. The encoder-side opt-in toggle is the blocker; the decode-side auto-verify is a nice-to-have that would let us drop hand-rolled comparison.
Versions: structured-zstd 0.0.26.
Problem
FrameCompressorties the content-checksum (the 4-byte XXH64 frame trailer) to thehashcargo feature with no runtime opt-out:So with
hashenabled, every emitted frame carries a content checksum: the encoder XXH64-hashes the full uncompressed input and appends 4 bytes. There is noFrameCompressormethod to disable it per-instance/per-frame, andcompress_to_vec/compressexpose no knob either.For a consumer that wants the checksum only as an opt-in diagnostic on selected frames (and a zero-overhead default elsewhere), this is all-or-nothing: enabling the feature forces the hash + 4 bytes onto the hot path globally.
Request
Add an opt-in setter so content-checksum emission is per-instance, defaulting to the current
cfg!(feature = "hash")behaviour for backwards compatibility:(Name/shape up to you —
set_content_checksum, a builder arg, etc. The need is a runtime toggle, not a new compile-time feature.)Decode side (related)
On the read side,
FrameDecoderreads the trailer (get_checksum_from_data()) and can compute the running digest (get_calculated_checksum(), behindhash), butdecode_all/decode_all_to_vecdo not automatically compare calculated vs stored — there is noChecksumMismatcherror variant. A consumer that wants the checksum to actually gate decode currently has to call both accessors and compare by hand after a full decode.Would be useful (optionally, behind
hash/ a decoder flag) to have the decode path verify the trailer and surface a typedFrameDecoderError::ContentChecksumMismatch { expected, found }so the checksum can be used as an integrity gate without manual post-hoc comparison.Use case
coordinode-lsm-tree wants content-checksum as an opt-in encoder-correctness diagnostic (catch
decompress(compress(x)) != xfrom an encoder bug) on a subset of writes, with the mandatory write path paying zero extra cost. The encoder-side opt-in toggle is the blocker; the decode-side auto-verify is a nice-to-have that would let us drop hand-rolled comparison.Versions: structured-zstd 0.0.26.