[][src]Struct tide::http::transfer::TE

pub struct TE { /* fields omitted */ }

Client header advertising the transfer encodings the user agent is willing to accept.

MDN Documentation

Specifications

Examples

use http_types::transfer::{TE, TransferEncoding, Encoding, EncodingProposal};
use http_types::Response;

let mut te = TE::new();
te.push(EncodingProposal::new(Encoding::Brotli, Some(0.8))?);
te.push(EncodingProposal::new(Encoding::Gzip, Some(0.4))?);
te.push(EncodingProposal::new(Encoding::Identity, None)?);

let mut res = Response::new(200);
let encoding = te.negotiate(&[Encoding::Brotli, Encoding::Gzip])?;
encoding.apply(&mut res);

assert_eq!(res["Content-Encoding"], "br");

Implementations

impl TE[src]

pub fn new() -> TE[src]

Create a new instance of TE.

pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<TE>, Error>[src]

Create an instance of TE from a Headers instance.

pub fn push(&mut self, prop: impl Into<EncodingProposal>)[src]

Push a directive into the list of entries.

pub fn wildcard(&self) -> bool[src]

Returns true if a wildcard directive was passed.

pub fn set_wildcard(&mut self, wildcard: bool)[src]

Set the wildcard directive.

pub fn sort(&mut self)[src]

Sort the header directives by weight.

Headers with a higher q= value will be returned first. If two directives have the same weight, the directive that was declared later will be returned first.

pub fn negotiate(
    &mut self,
    available: &[Encoding]
) -> Result<TransferEncoding, Error>
[src]

Determine the most suitable Content-Type encoding.

Errors

If no suitable encoding is found, an error with the status of 406 will be returned.

pub fn apply(&self, headers: impl AsMut<Headers>)[src]

Sets the Accept-Encoding header.

pub fn name(&self) -> HeaderName[src]

Get the HeaderName.

pub fn value(&self) -> HeaderValue[src]

Get the HeaderValue.

pub fn iter(&self) -> Iter<'_>[src]

An iterator visiting all entries.

pub fn iter_mut(&mut self) -> IterMut<'_>[src]

An iterator visiting all entries.

Trait Implementations

impl Debug for TE[src]

impl IntoIterator for TE[src]

type Item = EncodingProposal

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut TE[src]

type Item = &'a mut EncodingProposal

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a TE[src]

type Item = &'a EncodingProposal

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

impl ToHeaderValues for TE[src]

type Iter = IntoIter<HeaderValue>

Returned iterator over header values which this type may correspond to.

Auto Trait Implementations

impl RefUnwindSafe for TE[src]

impl Send for TE[src]

impl Sync for TE[src]

impl Unpin for TE[src]

impl UnwindSafe for TE[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,