Skip to main content

compress

Function compress 

Source
pub fn compress(
    body: &[u8],
    algo: Algorithm,
) -> Result<CompressedBody, CompressionError>
Expand description

Compress body with a single algorithm. Returns the raw compressed bytes + the matching Content-Encoding header value.

§Errors

Returns CompressionError if the underlying encoder fails. In practice this is rare for in-memory operations — gzip/deflate/ brotli never error on well-formed input slices.