Struct trillium_http_types::content::AcceptEncoding [−][src]
pub struct AcceptEncoding { /* fields omitted */ }Expand description
Client header advertising available compression algorithms.
Specifications
Examples
use http_types::content::{AcceptEncoding, ContentEncoding, Encoding, EncodingProposal}; use http_types::Response; let mut accept = AcceptEncoding::new(); accept.push(EncodingProposal::new(Encoding::Brotli, Some(0.8))?); accept.push(EncodingProposal::new(Encoding::Gzip, Some(0.4))?); accept.push(EncodingProposal::new(Encoding::Identity, None)?); let mut res = Response::new(200); let encoding = accept.negotiate(&[Encoding::Brotli, Encoding::Gzip])?; res.insert_header(&encoding, &encoding); assert_eq!(res["Content-Encoding"], "br");
Implementations
Create an instance of AcceptEncoding from a Headers instance.
Push a directive into the list of entries.
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 Content-Type encoding.
Errors
If no suitable encoding is found, an error with the status of 406 will be returned.
An iterator visiting all entries.
Trait Implementations
Access the header’s name.
Access the header’s value.
Auto Trait Implementations
impl RefUnwindSafe for AcceptEncodingimpl Send for AcceptEncodingimpl Sync for AcceptEncodingimpl Unpin for AcceptEncodingimpl UnwindSafe for AcceptEncoding