Decode a [`Body`] with featured decoder. Symmetric to [`encode_body`](Self::encode_body). Use this when decoding outside of an HTTP response context (e.g. gRPC request decompression) where the encoding is determined by a protocol-specific header rather than `Content-Encoding`.
(self, body: S)
| 129 | /// an HTTP response context (e.g. gRPC request decompression) where the encoding is |
| 130 | /// determined by a protocol-specific header rather than `Content-Encoding`. |
| 131 | pub fn decode_body<S>(self, body: S) -> Coder<S, FeaturedCode> |
| 132 | where |
| 133 | S: Body, |
| 134 | S::Data: AsRef<[u8]> + 'static, |
| 135 | { |
| 136 | let decoder = match self { |
| 137 | #[cfg(feature = "de")] |
| 138 | ContentEncoding::Deflate => { |
| 139 | FeaturedCode::DecodeDe(super::deflate::Decoder::new(super::writer::BytesMutWriter::new())) |
| 140 | } |
| 141 | #[cfg(feature = "gz")] |
| 142 | ContentEncoding::Gzip => { |
| 143 | FeaturedCode::DecodeGz(super::gzip::Decoder::new(super::writer::BytesMutWriter::new())) |
| 144 | } |
| 145 | #[cfg(feature = "br")] |
| 146 | ContentEncoding::Br => FeaturedCode::DecodeBr(super::brotli::Decoder::new()), |
| 147 | #[cfg(feature = "zs")] |
| 148 | ContentEncoding::Zstd => FeaturedCode::DecodeZs(super::zstandard::Decoder::new()), |
| 149 | _ => FeaturedCode::default(), |
| 150 | }; |
| 151 | |
| 152 | Coder::new(body, decoder) |
| 153 | } |
| 154 | |
| 155 | fn update_header(self, headers: &mut HeaderMap, version: http::Version) { |
| 156 | if matches!(self, ContentEncoding::Identity) { |