Skip to main content

Module encoding

Module encoding 

Source
Expand description

Per-message compression negotiation and codecs.

The wire surface is two HTTP/2 headers plus the per-message Compressed-Flag byte:

  • grpc-encoding: encoding the sender used for its messages (request → request body messages; response → response body messages).
  • grpc-accept-encoding: comma-separated list the sender will accept on the peer’s messages.

Encoding enumerates the codecs trillium-grpc was built with. The Identity variant is always present; Gzip, Deflate, and Zstd are cfg-gated on their respective Cargo features. gzip is on by default because it’s the de-facto baseline for gRPC compression in the wild.

Compression is one-shot (bytes → bytes) on per-message buffers, so we use the synchronous codec crates directly (flate2 for gzip+deflate, zstd for zstd). The async-compression wrappers would only add AsyncRead-shaped ceremony for what is fundamentally a small in-memory transformation.

Enums§

Encoding
A per-message compression codec. Which variants exist depends on the enabled Cargo features; Identity (no compression) is always present.

Constants§

DEFAULT_MAX_MESSAGE_SIZE
Default cap on a single decompressed message, matching grpc-go’s default and the per-frame max_message_size in crate::frame::reader.