pub struct TE { /* private fields */ }
Expand description

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

Create a new instance of TE.

Create an instance of TE from a Headers instance.

Push a directive into the list of entries.

Returns true if a wildcard directive was passed.

Set the wildcard directive.

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.

Determine the most suitable Transfer-Encoding encoding.

Errors

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

Sets the Accept-Encoding header.

Get the HeaderName.

Get the HeaderValue.

An iterator visiting all entries.

An iterator visiting all entries.

Trait Implementations

Formats the value using the given formatter. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

Converts this object to an iterator of resolved HeaderValues.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.