Skip to main content

decode_envelope_from_bytes_with_cap

Function decode_envelope_from_bytes_with_cap 

Source
pub fn decode_envelope_from_bytes_with_cap(
    bytes: &[u8],
    hmac_key: &[u8; 32],
    max_decompressed: usize,
) -> Result<Vec<u8>, ArtifactError>
Expand description

Decode the unified artifact-store envelope from bytes, like decode_envelope_from_bytes, but with a caller-supplied max_decompressed ceiling instead of the crate-wide MAX_DECOMPRESSED_LEN.

This exists so a consumer with its own decompressed-size budget — the snapshot reader’s with_max_decompressed knob is the motivating case — can enforce a tighter (or looser) zip-bomb cap than the default without round-tripping through the disk store. decode_envelope_from_bytes is a thin wrapper that calls this with max_decompressed = MAX_DECOMPRESSED_LEN.

Behaviour, validation order, and error surface are otherwise identical to decode_envelope_from_bytes: the only difference is which ceiling drives the Take probe and the post-decode ArtifactError::TooLarge check.