feat(header): add Encoding::Brotli variant

BREAKING CHANGE: This adds a new variant to the `Encoding` enum, which
  can break exhaustive matches.
This commit is contained in:
Sean McArthur
2017-01-14 09:39:05 -08:00
parent cd9fd52207
commit f0ab2b6aed

View File

@@ -1,7 +1,7 @@
use std::fmt; use std::fmt;
use std::str; use std::str;
pub use self::Encoding::{Chunked, Gzip, Deflate, Compress, Identity, EncodingExt}; pub use self::Encoding::{Chunked, Brotli, Gzip, Deflate, Compress, Identity, EncodingExt};
/// A value to represent an encoding used in `Transfer-Encoding` /// A value to represent an encoding used in `Transfer-Encoding`
/// or `Accept-Encoding` header. /// or `Accept-Encoding` header.
@@ -9,6 +9,8 @@ pub use self::Encoding::{Chunked, Gzip, Deflate, Compress, Identity, EncodingExt
pub enum Encoding { pub enum Encoding {
/// The `chunked` encoding. /// The `chunked` encoding.
Chunked, Chunked,
/// The `br` encoding.
Brotli,
/// The `gzip` encoding. /// The `gzip` encoding.
Gzip, Gzip,
/// The `deflate` encoding. /// The `deflate` encoding.
@@ -25,6 +27,7 @@ impl fmt::Display for Encoding {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self { f.write_str(match *self {
Chunked => "chunked", Chunked => "chunked",
Brotli => "br",
Gzip => "gzip", Gzip => "gzip",
Deflate => "deflate", Deflate => "deflate",
Compress => "compress", Compress => "compress",
@@ -39,6 +42,7 @@ impl str::FromStr for Encoding {
fn from_str(s: &str) -> ::Result<Encoding> { fn from_str(s: &str) -> ::Result<Encoding> {
match s { match s {
"chunked" => Ok(Chunked), "chunked" => Ok(Chunked),
"br" => Ok(Brotli),
"deflate" => Ok(Deflate), "deflate" => Ok(Deflate),
"gzip" => Ok(Gzip), "gzip" => Ok(Gzip),
"compress" => Ok(Compress), "compress" => Ok(Compress),