pub enum ContentCoding {
    BROTLI,
    COMPRESS,
    DEFLATE,
    GZIP,
    IDENTITY,
    ZSTD,
}
Expand description

Values that are used with headers like Content-Encoding or Accept-Encoding

RFC7231

Variants§

§

BROTLI

br

§

COMPRESS

compress

§

DEFLATE

deflate

§

GZIP

gzip

§

IDENTITY

identity

§

ZSTD

zstd

Implementations§

source§

impl ContentCoding

source

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");
source

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);
source

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

source§

fn clone(&self) -> ContentCoding

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ContentCoding

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<ContentCoding> for HeaderValue

source§

fn from(coding: ContentCoding) -> HeaderValue

Converts to this type from the input type.
source§

impl PartialEq<ContentCoding> for ContentCoding

source§

fn eq(&self, other: &ContentCoding) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToString for ContentCoding

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl Copy for ContentCoding

source§

impl Eq for ContentCoding

source§

impl StructuralEq for ContentCoding

source§

impl StructuralPartialEq for ContentCoding

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.