pub enum ContentCoding {
BROTLI,
COMPRESS,
DEFLATE,
GZIP,
IDENTITY,
}
Expand description
Values that are used with headers like Content-Encoding
or
Accept-Encoding
Variants§
Implementations§
source§impl ContentCoding
impl ContentCoding
sourcepub fn to_static(&self) -> &'static str
pub fn to_static(&self) -> &'static str
Returns a &'static str
for a ContentCoding
Example
use headers::ContentCoding;
let coding = ContentCoding::BROTLI;
assert_eq!(coding.to_static(), "br");
sourcepub fn from_str(s: &str) -> Self
pub fn from_str(s: &str) -> Self
Given a &str
returns a ContentCoding
Note this will never fail, in the case of &str
being an invalid content coding,
will return ContentCoding::IDENTITY
because 'identity'
is generally always an
accepted coding.
Example
use headers::ContentCoding;
let invalid = ContentCoding::from_str("not a valid coding");
assert_eq!(invalid, ContentCoding::IDENTITY);
let valid = ContentCoding::from_str("gzip");
assert_eq!(valid, ContentCoding::GZIP);
sourcepub fn try_from_str(s: &str) -> Result<Self, ()>
pub fn try_from_str(s: &str) -> Result<Self, ()>
Given a &str
will try to return a ContentCoding
Different from ContentCoding::from_str(&str)
, if &str
is an invalid content
coding, it will return Err(())
Example
use headers::ContentCoding;
let invalid = ContentCoding::try_from_str("not a valid coding");
assert!(invalid.is_err());
let valid = ContentCoding::try_from_str("gzip");
assert_eq!(valid.unwrap(), ContentCoding::GZIP);
Trait Implementations§
source§impl Clone for ContentCoding
impl Clone for ContentCoding
source§fn clone(&self) -> ContentCoding
fn clone(&self) -> ContentCoding
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ContentCoding
impl Debug for ContentCoding
source§impl From<ContentCoding> for HeaderValue
impl From<ContentCoding> for HeaderValue
source§fn from(coding: ContentCoding) -> HeaderValue
fn from(coding: ContentCoding) -> HeaderValue
Converts to this type from the input type.
source§impl PartialEq<ContentCoding> for ContentCoding
impl PartialEq<ContentCoding> for ContentCoding
source§fn eq(&self, other: &ContentCoding) -> bool
fn eq(&self, other: &ContentCoding) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.