pub struct TE { /* private fields */ }
Expand description
Client header advertising the transfer encodings the user agent is willing to accept.
§Specifications
§Examples
use http_types_rs::transfer::{TE, TransferEncoding, Encoding, EncodingProposal};
use http_types_rs::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])?;
res.insert_header(&encoding, &encoding);
assert_eq!(res["Transfer-Encoding"], "br");
Implementations§
Source§impl TE
impl TE
Sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create an instance of TE
from a Headers
instance.
Sourcepub fn push(&mut self, prop: impl Into<EncodingProposal>)
pub fn push(&mut self, prop: impl Into<EncodingProposal>)
Push a directive into the list of entries.
Sourcepub fn set_wildcard(&mut self, wildcard: bool)
pub fn set_wildcard(&mut self, wildcard: bool)
Set the wildcard directive.
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
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.
Trait Implementations§
Source§impl Header for TE
impl Header for TE
Source§fn header_name(&self) -> HeaderName
fn header_name(&self) -> HeaderName
Access the header’s name.
Source§fn header_value(&self) -> HeaderValue
fn header_value(&self) -> HeaderValue
Access the header’s value.
Source§impl<'a> IntoIterator for &'a TE
impl<'a> IntoIterator for &'a TE
Source§impl<'a> IntoIterator for &'a mut TE
impl<'a> IntoIterator for &'a mut TE
Auto Trait Implementations§
impl Freeze for TE
impl RefUnwindSafe for TE
impl Send for TE
impl Sync for TE
impl Unpin for TE
impl UnwindSafe for TE
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> ToHeaderValues for Twhere
T: Header,
impl<T> ToHeaderValues for Twhere
T: Header,
Source§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Source§fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved
HeaderValues
.