pub fn select_zstd_dict_for_response<'a>(
response_headers: &HashMap<String, String>,
loaded_dicts: &'a HashMap<String, Vec<u8>>,
) -> Result<Option<&'a [u8]>, CodecZstdDictError>Expand description
Pick the zstd dict to decompress this response with.
§Parameters
response_headers: HTTP response header map. Keys are looked up case-insensitively, matching the wayreqwest::HeaderMapand most HTTP libraries treat headers on the wire.loaded_dicts:{ "sha256:<hex>" -> dict bytes }. Populate this from your tokenizer map’szstd_dictionaries[]entries; keys follow the same canonical shape the server emits.
§Returns
Ok(Some(&dict_bytes))when the response isContent-Encoding: zstdand the server’sCodec-Zstd-Dictheader points at a loaded dict — pass these bytes to your zstd decoder (e.g.zstd::stream::Decoder::with_dictionary).Ok(None)when the response isn’t zstd. The caller should pass the body through identity / let its HTTP stack auto-decompress gzip / brotli.
§Errors
Returns CodecZstdDictError when the response is zstd but the
header is missing, malformed, or names a dict the client hasn’t
loaded. Wrong-dict decompression is never attempted — see the
spec rationale at spec/PROTOCOL.md.