pub enum ContentCoding {
BROTLI,
COMPRESS,
DEFLATE,
GZIP,
IDENTITY,
ZSTD,
}
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 for ContentCoding
impl PartialEq for ContentCoding
Source§impl ToString for ContentCoding
impl ToString for ContentCoding
impl Copy for ContentCoding
impl Eq for ContentCoding
impl StructuralPartialEq for ContentCoding
Auto Trait Implementations§
impl Freeze for ContentCoding
impl RefUnwindSafe for ContentCoding
impl Send for ContentCoding
impl Sync for ContentCoding
impl Unpin for ContentCoding
impl UnwindSafe for ContentCoding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more