kutil_http/headers/
encoding.rs1use super::into::*;
2
3use {http::header::*, kutil_std::*, kutil_transcoding::*, std::convert::*};
4
5impl IntoHeaderValue for Encoding {
6 fn into_header_value(self) -> HeaderValue {
7 let value: EncodingHeaderValue = self.into();
8 value.into()
9 }
10}
11
12#[derive(Clone, Copy, Debug, Default, Display, FromStr, Eq, Hash, PartialEq)]
18#[display(lowercase)]
19#[from_str(lowercase)]
20pub enum EncodingHeaderValue {
21 #[default]
23 Identity,
24
25 #[strings("br")]
27 Brotli,
28
29 Deflate,
31
32 GZip,
34
35 #[strings("zstd")]
37 Zstandard,
38}
39
40impl From<Encoding> for EncodingHeaderValue {
41 fn from(encoding: Encoding) -> Self {
42 match encoding {
43 Encoding::Identity => Self::Identity,
44 Encoding::Brotli => Self::Brotli,
45 Encoding::Deflate => Self::Deflate,
46 Encoding::GZip => Self::GZip,
47 Encoding::Zstandard => Self::Zstandard,
48 }
49 }
50}
51
52impl Into<Encoding> for EncodingHeaderValue {
53 fn into(self) -> Encoding {
54 match self {
55 Self::Identity => Encoding::Identity,
56 Self::Brotli => Encoding::Brotli,
57 Self::Deflate => Encoding::Deflate,
58 Self::GZip => Encoding::GZip,
59 Self::Zstandard => Encoding::Zstandard,
60 }
61 }
62}
63
64impl Into<HeaderValue> for EncodingHeaderValue {
65 fn into(self) -> HeaderValue {
66 HeaderValue::from_static(self.into())
67 }
68}