pub struct Negotiator<'a> {
pub accept: Option<&'a str>,
pub accept_charset: Option<&'a str>,
pub accept_encoding: Option<&'a str>,
pub accept_language: Option<&'a str>,
}Expand description
A content negotiator over a request’s Accept* headers.
Construct one with Negotiator::new and the chainable setters, then call the
negotiation methods. Each method takes available = Some(list) to pick from the
server’s options, or None to list everything the client accepts.
Fields§
§accept: Option<&'a str>The Accept header value.
accept_charset: Option<&'a str>The Accept-Charset header value.
accept_encoding: Option<&'a str>The Accept-Encoding header value.
accept_language: Option<&'a str>The Accept-Language header value.
Implementations§
Source§impl<'a> Negotiator<'a>
impl<'a> Negotiator<'a>
Sourcepub fn accept_charset(self, value: &'a str) -> Self
pub fn accept_charset(self, value: &'a str) -> Self
Set the Accept-Charset header.
Sourcepub fn accept_encoding(self, value: &'a str) -> Self
pub fn accept_encoding(self, value: &'a str) -> Self
Set the Accept-Encoding header.
Sourcepub fn accept_language(self, value: &'a str) -> Self
pub fn accept_language(self, value: &'a str) -> Self
Set the Accept-Language header.
Sourcepub fn media_types(&self, available: Option<&[&str]>) -> Vec<String>
pub fn media_types(&self, available: Option<&[&str]>) -> Vec<String>
All acceptable media types, or the preferred subset of available.
Sourcepub fn media_type(&self, available: Option<&[&str]>) -> Option<String>
pub fn media_type(&self, available: Option<&[&str]>) -> Option<String>
The single most-preferred media type from available.
Sourcepub fn charsets(&self, available: Option<&[&str]>) -> Vec<String>
pub fn charsets(&self, available: Option<&[&str]>) -> Vec<String>
All acceptable charsets, or the preferred subset of available.
Sourcepub fn charset(&self, available: Option<&[&str]>) -> Option<String>
pub fn charset(&self, available: Option<&[&str]>) -> Option<String>
The single most-preferred charset from available.
Sourcepub fn encodings(
&self,
available: Option<&[&str]>,
preferred: Option<&[&str]>,
) -> Vec<String>
pub fn encodings( &self, available: Option<&[&str]>, preferred: Option<&[&str]>, ) -> Vec<String>
All acceptable encodings, or the preferred subset of available.
preferred biases quality ties toward a server-preferred order.
Sourcepub fn encoding(
&self,
available: Option<&[&str]>,
preferred: Option<&[&str]>,
) -> Option<String>
pub fn encoding( &self, available: Option<&[&str]>, preferred: Option<&[&str]>, ) -> Option<String>
The single most-preferred encoding from available.
Trait Implementations§
Source§impl<'a> Clone for Negotiator<'a>
impl<'a> Clone for Negotiator<'a>
Source§fn clone(&self) -> Negotiator<'a>
fn clone(&self) -> Negotiator<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for Negotiator<'a>
Source§impl<'a> Debug for Negotiator<'a>
impl<'a> Debug for Negotiator<'a>
Source§impl<'a> Default for Negotiator<'a>
impl<'a> Default for Negotiator<'a>
Source§fn default() -> Negotiator<'a>
fn default() -> Negotiator<'a>
impl<'a> Eq for Negotiator<'a>
Source§impl<'a> PartialEq for Negotiator<'a>
impl<'a> PartialEq for Negotiator<'a>
Source§fn eq(&self, other: &Negotiator<'a>) -> bool
fn eq(&self, other: &Negotiator<'a>) -> bool
self and other values to be equal, and is used by ==.