maybe_compress

Function maybe_compress 

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

Compress a payload if it exceeds the threshold.

Returns the original bytes if:

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

Returns a compressed wrapper JSON if compression is beneficial.