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::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`
/// or `Accept-Encoding` header.
@@ -9,6 +9,8 @@ pub use self::Encoding::{Chunked, Gzip, Deflate, Compress, Identity, EncodingExt
pub enum Encoding {
/// The `chunked` encoding.
Chunked,
/// The `br` encoding.
Brotli,
/// The `gzip` encoding.
Gzip,
/// The `deflate` encoding.
@@ -25,6 +27,7 @@ impl fmt::Display for Encoding {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self {
Chunked => "chunked",
Brotli => "br",
Gzip => "gzip",
Deflate => "deflate",
Compress => "compress",
@@ -39,6 +42,7 @@ impl str::FromStr for Encoding {
fn from_str(s: &str) -> ::Result<Encoding> {
match s {
"chunked" => Ok(Chunked),
"br" => Ok(Brotli),
"deflate" => Ok(Deflate),
"gzip" => Ok(Gzip),
"compress" => Ok(Compress),