pub struct ContentEncoding(pub NonEmptyVec<ContentEncodingDirective>);Expand description
Content-Encoding header, defined in
RFC7231
The Content-Encoding header field indicates what content codings
have been applied to the representation, beyond those inherent in the
media type, and thus what decoding mechanisms have to be applied in
order to obtain data in the media type referenced by the Content-Type
header field. Content-Encoding is primarily used to allow a
representation’s data to be compressed without losing the identity of
its underlying media type.
§ABNF
Content-Encoding = 1#content-coding§Example values
gzipbrzstddeflate, gzip
§Examples
use rama_http_headers::ContentEncoding;
let content_enc = ContentEncoding::gzip();Tuple Fields§
§0: NonEmptyVec<ContentEncodingDirective>Implementations§
Source§impl ContentEncoding
impl ContentEncoding
pub fn new(value: ContentEncodingDirective) -> ContentEncoding
Source§impl ContentEncoding
impl ContentEncoding
Sourcepub fn new_multi(
directives: NonEmptyVec<ContentEncodingDirective>,
) -> ContentEncoding
pub fn new_multi( directives: NonEmptyVec<ContentEncodingDirective>, ) -> ContentEncoding
Create a new ContentEncoding header with multiple directives.
Meaning the content is encoded with all given directives and in order.
Sourcepub fn gzip() -> ContentEncoding
pub fn gzip() -> ContentEncoding
A constructor to easily create a Content-Encoding: gzip header.
Sourcepub fn brotli() -> ContentEncoding
pub fn brotli() -> ContentEncoding
A constructor to easily create a Content-Encoding: br header.
Sourcepub fn zstd() -> ContentEncoding
pub fn zstd() -> ContentEncoding
A constructor to easily create a Content-Encoding: zstd header.
Sourcepub fn contains_directive(&self, coding: impl CmpCoding) -> bool
pub fn contains_directive(&self, coding: impl CmpCoding) -> bool
Check if this header contains a given “coding”.
This can be used with these argument types:
&str
§Example
use rama_http_headers::ContentEncoding;
let content_enc = ContentEncoding::gzip();
assert!(content_enc.contains_directive("gzip"));
assert!(!content_enc.contains_directive("br"));Trait Implementations§
Source§impl Clone for ContentEncoding
impl Clone for ContentEncoding
Source§fn clone(&self) -> ContentEncoding
fn clone(&self) -> ContentEncoding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentEncoding
impl Debug for ContentEncoding
Source§impl HeaderDecode for ContentEncoding
impl HeaderDecode for ContentEncoding
Source§fn decode<'i, I>(values: &mut I) -> Result<ContentEncoding, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<ContentEncoding, Error>where
I: Iterator<Item = &'i HeaderValue>,
HeaderValues.Source§impl HeaderEncode for ContentEncoding
impl HeaderEncode for ContentEncoding
Source§fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
HeaderValue, and add it to a container
which has HeaderValue type as each element. Read moreSource§fn encode_to_value(&self) -> Option<HeaderValue>
fn encode_to_value(&self) -> Option<HeaderValue>
HeaderValue. Read moreSource§impl TypedHeader for ContentEncoding
impl TypedHeader for ContentEncoding
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
Auto Trait Implementations§
impl Freeze for ContentEncoding
impl RefUnwindSafe for ContentEncoding
impl Send for ContentEncoding
impl Sync for ContentEncoding
impl Unpin for ContentEncoding
impl UnsafeUnpin for ContentEncoding
impl UnwindSafe for ContentEncoding
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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