Expand description
Client-side helpers for the Codec compression contract.
Rust twin of codecai.compression (Python): the server emits
Codec-Zstd-Dict: sha256:<hex> on every zstd response, the client
validates that header against locally-loaded dicts before
decompressing. See spec/PROTOCOL.md “Codec-Zstd-Dict response
header” (stable since v0.2) for the full contract.
The actual zstd decompression is intentionally out of scope here —
callers usually already have an HTTP stack and pick their own
zstd binding (zstd crate, zstd-safe, an FFI wrapper, etc.).
This module just gives you the small piece that’s specific to
Codec: matching a response’s declared dict hash to the dict you’ve
loaded, with the case-insensitive header lookup and fail-fast
semantics the spec mandates.
Wrong-dict decompression produces garbage bytes that downstream msgpack / protobuf parsers will silently misinterpret — fail fast at the dict-select boundary instead.
Enums§
- Codec
Zstd Dict Error - Raised when the server’s
Codec-Zstd-Dictheader doesn’t match any dict the client has loaded, or is missing on a zstd response. - Zstd
Dict Discovery Error - Errors raised by the v0.5 zstd-dictionary discovery surface.
Functions§
- discover_
zstd_ dict - Async variant of
discover_zstd_dict_blocking. Requires a Tokio runtime. - discover_
zstd_ dict_ blocking - Synchronously resolve a zstd dictionary via
.well-known/codec/dicts/<hex>.zstd(v0.5+). - hash_
zstd_ dict - Compute the canonical
Codec-Zstd-Dicthash fordict_bytes. - select_
zstd_ dict_ for_ response - Pick the zstd dict to decompress this response with.
- well_
known_ dict_ url - Per-dict document URL for an origin + sha256 hash (v0.5+).