Struct actix_web::http::header::AcceptLanguage [−][src]
pub struct AcceptLanguage(pub Vec<QualityItem<LanguageTag>>);
Expand description
Accept-Language header, defined in
RFC7231
The Accept-Language header field can be used by user agents to
indicate the set of natural languages that are preferred in the
response.
ABNF
Accept-Language = 1#( language-range [ weight ] )
language-range = <language-range, see [RFC4647], Section 2.1>
Example values
da, en-gb;q=0.8, en;q=0.7en-us;q=1.0, en;q=0.5, fr
Examples
use actix_web::HttpResponse; use actix_web::http::header::{AcceptLanguage, LanguageTag, qitem}; let mut builder = HttpResponse::Ok(); let langtag = LanguageTag::parse("en-US").unwrap(); builder.insert_header( AcceptLanguage(vec![ qitem(langtag), ]) );
use actix_web::HttpResponse; use actix_web::http::header::{AcceptLanguage, LanguageTag, QualityItem, q, qitem}; let mut builder = HttpResponse::Ok(); builder.insert_header( AcceptLanguage(vec![ qitem(LanguageTag::parse("da").unwrap()), QualityItem::new(LanguageTag::parse("en-GB").unwrap(), q(800)), QualityItem::new(LanguageTag::parse("en").unwrap(), q(700)), ]) );
Trait Implementations
type Target = Vec<QualityItem<LanguageTag>>
type Target = Vec<QualityItem<LanguageTag>>The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Returns the name of the header field
Parse a header
type Error = InvalidHeaderValue
type Error = InvalidHeaderValueThe type returned in the event of a conversion error.
Try to convert value to a HeaderValue.
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl RefUnwindSafe for AcceptLanguageimpl Send for AcceptLanguageimpl Sync for AcceptLanguageimpl Unpin for AcceptLanguageimpl UnwindSafe for AcceptLanguageBlanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Error = <T as IntoHeaderValue>::Errorpub fn try_into_header_pair(
self
) -> Result<(HeaderName, HeaderValue), <T as IntoHeaderPair>::Error>type Output = T
type Output = TShould always be Self
pub fn vzip(self) -> V