• Home
  • Raw
  • Download

Lines Matching +full:zstd +full:-

7 #[cfg(feature = "zstd")]
8 use zstd::stream::read::{Decoder, Encoder};
10 pub(crate) const ENCODING_HEADER: &str = "grpc-encoding";
11 pub(crate) const ACCEPT_ENCODING_HEADER: &str = "grpc-accept-encoding";
18 #[cfg(feature = "zstd")]
19 pub(crate) zstd: bool, field
24 pub fn is_enabled(&self, encoding: CompressionEncoding) -> bool { in is_enabled()
28 #[cfg(feature = "zstd")] in is_enabled()
29 CompressionEncoding::Zstd => self.zstd, in is_enabled()
38 #[cfg(feature = "zstd")] in enable()
39 CompressionEncoding::Zstd => self.zstd = true, in enable()
43 pub(crate) fn into_accept_encoding_header_value(self) -> Option<http::HeaderValue> { in into_accept_encoding_header_value()
46 (false, true) => Some(http::HeaderValue::from_static("zstd,identity")), in into_accept_encoding_header_value()
47 (true, true) => Some(http::HeaderValue::from_static("gzip,zstd,identity")), in into_accept_encoding_header_value()
53 const fn is_gzip_enabled(&self) -> bool { in is_gzip_enabled()
58 const fn is_gzip_enabled(&self) -> bool { in is_gzip_enabled()
62 #[cfg(feature = "zstd")]
63 const fn is_zstd_enabled(&self) -> bool { in is_zstd_enabled()
64 self.zstd in is_zstd_enabled()
67 #[cfg(not(feature = "zstd"))]
68 const fn is_zstd_enabled(&self) -> bool { in is_zstd_enabled()
82 #[cfg(feature = "zstd")]
83 #[cfg_attr(docsrs, doc(cfg(feature = "zstd")))]
84 Zstd, enumerator
88 /// Based on the `grpc-accept-encoding` header, pick an encoding to use.
92 ) -> Option<Self> { in from_accept_encoding_header()
103 #[cfg(feature = "zstd")] in from_accept_encoding_header()
104 "zstd" => Some(CompressionEncoding::Zstd), in from_accept_encoding_header()
109 /// Get the value of `grpc-encoding` header. Returns an error if the encoding isn't supported.
113 ) -> Result<Option<Self>, Status> { in from_encoding_header()
131 #[cfg(feature = "zstd")] in from_encoding_header()
132 "zstd" if enabled_encodings.is_enabled(CompressionEncoding::Zstd) => { in from_encoding_header()
133 Ok(Some(CompressionEncoding::Zstd)) in from_encoding_header()
156 #[cfg(any(feature = "gzip", feature = "zstd"))]
157 pub(crate) fn as_str(&self) -> &'static str { in as_str()
161 #[cfg(feature = "zstd")] in as_str()
162 CompressionEncoding::Zstd => "zstd", in as_str()
166 #[cfg(any(feature = "gzip", feature = "zstd"))]
167 pub(crate) fn into_header_value(self) -> http::HeaderValue { in into_header_value()
171 pub(crate) fn encodings() -> &'static [Self] { in encodings()
175 #[cfg(feature = "zstd")] in encodings()
176 CompressionEncoding::Zstd, in encodings()
183 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
187 #[cfg(feature = "zstd")] in fmt()
188 CompressionEncoding::Zstd => write!(f, "zstd"), in fmt()
193 fn split_by_comma(s: &str) -> impl Iterator<Item = &str> { in split_by_comma()
204 ) -> Result<(), std::io::Error> { in compress()
208 #[cfg(any(feature = "gzip", feature = "zstd"))] in compress()
221 #[cfg(feature = "zstd")] in compress()
222 CompressionEncoding::Zstd => { in compress()
226 zstd::DEFAULT_COMPRESSION_LEVEL, in compress()
244 ) -> Result<(), std::io::Error> { in decompress()
249 #[cfg(any(feature = "gzip", feature = "zstd"))] in decompress()
258 #[cfg(feature = "zstd")] in decompress()
259 CompressionEncoding::Zstd => { in decompress()
282 fn default() -> Self { in default()