http-compress 23.0.0

A high-performance async library for HTTP compression/decompression, supporting Brotli, Deflate, and Gzip algorithms. Provides both compression and decompression capabilities with optimized memory usage, ideal for HTTP clients/servers and network programming.
Documentation
/// Length in bytes of the fixed RFC 1952 gzip member header.
pub(crate) const GZIP_HEADER_LEN: usize = 10;

/// Length in bytes of the RFC 1952 gzip member trailer (CRC32 + ISIZE).
pub(crate) const GZIP_TRAILER_LEN: usize = 8;

/// Default RFC 1952 gzip header matching `flate2::GzBuilder::new()`.
pub(crate) const GZIP_DEFAULT_HEADER: [u8; GZIP_HEADER_LEN] =
    [0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff];

/// First RFC 1952 magic identification byte.
pub(crate) const GZIP_ID1: u8 = 0x1f;

/// Second RFC 1952 magic identification byte.
pub(crate) const GZIP_ID2: u8 = 0x8b;

/// RFC 1952 DEFLATE compression method identifier.
pub(crate) const GZIP_METHOD_DEFLATE: u8 = 8;

/// RFC 1952 header flag indicating a 16-bit header CRC is present.
pub(crate) const GZIP_FLAG_FHCRC: u8 = 1 << 1;

/// RFC 1952 header flag indicating an optional extra field is present.
pub(crate) const GZIP_FLAG_FEXTRA: u8 = 1 << 2;

/// RFC 1952 header flag indicating a NUL-terminated original filename is present.
pub(crate) const GZIP_FLAG_FNAME: u8 = 1 << 3;

/// RFC 1952 header flag indicating a NUL-terminated comment is present.
pub(crate) const GZIP_FLAG_FCOMMENT: u8 = 1 << 4;

/// Mask of reserved RFC 1952 header flag bits that must be zero.
pub(crate) const GZIP_FLAG_RESERVED: u8 = (1 << 5) | (1 << 6) | (1 << 7);

/// Maximum ratio of trusted trailer ISIZE hint relative to compressed input length.
pub(crate) const GZIP_HINT_MAX_RATIO: usize = 256;

/// Maximum direct preallocation size trusted from the trailer ISIZE hint when `buffer_size` is smaller.
pub(crate) const GZIP_HINT_DIRECT_CAP: usize = 65_536;

/// Extra headroom added to a trusted trailer ISIZE hint to avoid a final reallocation on `StreamEnd`.
pub(crate) const GZIP_HINT_HEADROOM: usize = 16;

/// Minimum fallback preallocation capacity when no trusted trailer ISIZE hint is available.
pub(crate) const GZIP_FALLBACK_RESERVE: usize = 4096;