Skip to main content

compress_payload

Function compress_payload 

Source
pub fn compress_payload(payload: &[u8]) -> Result<CompressedPayload>
Expand description

Compress a payload for sealing, choosing the codec per the SPEC §1.1 raw threshold.

Uses zstd (id 1) only when the payload is at least MIN_COMPRESS_BYTES AND zstd actually shrinks it; otherwise falls back to raw (id 0) so small or incompressible payloads never pay a header/ expansion penalty.

§Errors

MessageError::PayloadTooLarge if the payload does not fit the u32 length field; MessageError::Codec on a zstd encoder failure.