hyper_sync/header/shared/
encoding.rs1use std::fmt;
2use std::str;
3
4pub use self::Encoding::{Chunked, Brotli, Gzip, Deflate, Compress, Identity, EncodingExt, Trailers};
5
6#[derive(Clone, PartialEq, Debug)]
9pub enum Encoding {
10 Chunked,
12 Brotli,
14 Gzip,
16 Deflate,
18 Compress,
20 Identity,
22 Trailers,
24 EncodingExt(String)
26}
27
28impl fmt::Display for Encoding {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 f.write_str(match *self {
31 Chunked => "chunked",
32 Brotli => "br",
33 Gzip => "gzip",
34 Deflate => "deflate",
35 Compress => "compress",
36 Identity => "identity",
37 Trailers => "trailers",
38 EncodingExt(ref s) => s.as_ref()
39 })
40 }
41}
42
43impl str::FromStr for Encoding {
44 type Err = ::Error;
45 fn from_str(s: &str) -> ::Result<Encoding> {
46 match s {
47 "chunked" => Ok(Chunked),
48 "br" => Ok(Brotli),
49 "deflate" => Ok(Deflate),
50 "gzip" => Ok(Gzip),
51 "compress" => Ok(Compress),
52 "identity" => Ok(Identity),
53 "trailers" => Ok(Trailers),
54 _ => Ok(EncodingExt(s.to_owned()))
55 }
56 }
57}