maybe_compress

Function maybe_compress 

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

Compress a payload if it exceeds the threshold.

Returns CompressedPayload::Uncompressed if:

  • Payload is below threshold
  • Compression fails
  • Compressed size is larger than original (unlikely for JSON)

Returns CompressedPayload::Compressed with raw gzip bytes if compression is beneficial. The gzip data starts with magic bytes 0x1f 0x8b which clients use to detect compression.