# [−]Struct actix_web::http::header::LanguageTag

    pub struct LanguageTag {
        pub language: Option<String>,
        pub extlangs: Vec<String>,
        pub script: Option<String>,
        pub region: Option<String>,
        pub variants: Vec<String>,
        pub extensions: BTreeMap<u8, Vec<String>>,
        pub privateuse: Vec<String>,
    }

A language tag as described in BCP47.

Language tags are used to help identify languages, whether spoken, written, signed, or otherwise signaled, for the purpose of communication. This includes constructed and artificial languages but excludes languages not intended primarily for human communication, such as programming languages.

## Fields

`language: Option<String>`

Language subtags are used to indicate the language, ignoring all other aspects such as script, region or spefic invariants.

`extlangs: Vec<String>`

Extended language subtags are used to identify certain specially selected languages that, for various historical and compatibility reasons, are closely identified with or tagged using an existing primary language subtag.

`script: Option<String>`

Script subtags are used to indicate the script or writing system variations that distinguish the written forms of a language or its dialects.

`region: Option<String>`

Region subtags are used to indicate linguistic variations associated with or appropriate to a specific country, territory, or region. Typically, a region subtag is used to indicate variations such as regional dialects or usage, or region-specific spelling conventions. It can also be used to indicate that content is expressed in a way that is appropriate for use throughout a region, for instance, Spanish content tailored to be useful throughout Latin America.

`variants: Vec<String>`

Variant subtags are used to indicate additional, well-recognized variations that define a language or its dialects that are not covered by other available subtags.

`extensions: BTreeMap<u8, Vec<String>>`

Extensions provide a mechanism for extending language tags for use in various applications. They are intended to identify information that is commonly used in association with languages or language tags but that is not part of language identification.

`privateuse: Vec<String>`

Private use subtags are used to indicate distinctions in language that are important in a given context by private agreement.

## Methods

###

`impl LanguageTag`

####

`pub fn matches(&self, other: &LanguageTag) -> bool` |

Matches language tags. The first language acts as a language range, the second one is used as a normal language tag. None fields in the language range are ignored. If the language tag has more extlangs than the range these extlangs are ignored. Matches are case-insensitive. `*` in language ranges are represented using `None` values. The language range `*` that matches language tags is created by the default language tag: `let wildcard: LanguageTag = Default::default();.`

For example the range `en-GB` matches only `en-GB` and `en-Arab-GB` but not `en`. The range `en` matches all language tags starting with `en` including `en`, `en-GB`, `en-Arab` and `en-Arab-GB`.

# Panics

If the language range has extensions or private use tags.

# Examples

    let range_italian = langtag!(it);
    let tag_german = langtag!(de);
    let tag_italian_switzerland = langtag!(it;;;CH);
    assert!(!range_italian.matches(&tag_german));
    assert!(range_italian.matches(&tag_italian_switzerland));

    let range_spanish_brazil = langtag!(es;;;BR);
    let tag_spanish = langtag!(es);
    assert!(!range_spanish_brazil.matches(&tag_spanish));

####

`pub fn is_language_range(&self) -> bool` |

Checks if it is a language range, meaning that there are no extension and privateuse tags.

####

`pub fn canonicalize(&self) -> LanguageTag` |

Returns the canonical version of the language tag.

It currently applies the following steps:

- Grandfathered tags are replaced with the canonical version if possible.
- Extension languages are promoted to primary language.
- Deprecated languages are replaced with modern equivalents.
- Deprecated regions are replaced with new country names.
- The `heploc` variant is replaced with `alalc97`.

The returned language tags may not be completly canonical and they are not validated.

## Trait Implementations

###

`impl Debug for LanguageTag`

####

`fn fmt(&self, f: &mut Formatter) -> Result<(), Error>` |

Formats the value using the given formatter. Read more

###

`impl FromStr for LanguageTag`

#### `type Err = Error`

The associated error which can be returned from parsing.

####

`fn from_str(s: &str) -> Result<LanguageTag, Error>` |

Parses a string `s` to return a value of this type. Read more

###

`impl Clone for LanguageTag`

####

`fn clone(&self) -> LanguageTag` |

Returns a copy of the value. Read more

####

`fn clone_from(&mut self, source: &Self)`

1.0.0
[src]

Performs copy-assignment from `source`. Read more

###

`impl Default for LanguageTag`

####

`fn default() -> LanguageTag` |

Returns the "default value" for a type. Read more

###

`impl Eq for LanguageTag`

###

`impl PartialEq<LanguageTag> for LanguageTag`

####

`fn eq(&self, other: &LanguageTag) -> bool` |

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

####

`#[must_use] fn ne(&self, other: &Rhs) -> bool`

1.0.0
[src]

This method tests for `!=`.

###

`impl Display for LanguageTag`

####

`fn fmt(&self, f: &mut Formatter) -> Result<(), Error>` |

Formats the value using the given formatter. Read more

## Auto Trait Implementations

###

`impl Send for LanguageTag`

###

`impl Sync for LanguageTag`

## Blanket Implementations

###

`impl<T> ToOwned for T where T: Clone,`

[src]

#### `type Owned = T`

####

`fn to_owned(&self) -> T`

[src]

Creates owned data from borrowed data, usually by cloning. Read more

####

`fn clone_into(&self, target: &mut T)`

[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

###

`impl<T> ToString for T where T: Display + ?Sized,`

[src]

####

`fn to_string(&self) -> String`

[src]

Converts the given value to a `String`. Read more

###

`impl<T> From for T`

[src]

####

`fn from(t: T) -> T`

[src]

Performs the conversion.

###

`impl<T, U> Into for T where U: From<T>,`

[src]

####

`fn into(self) -> U`

[src]

Performs the conversion.

###

`impl<T, U> TryFrom for T where T: From<U>,`

[src]

#### `type Error = !`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Borrow for T where T: ?Sized,`

[src]

####

`fn borrow(&self) -> &T`

[src]

Immutably borrows from an owned value. Read more

###

`impl<T> BorrowMut for T where T: ?Sized,`

[src]

####

`fn borrow_mut(&mut self) -> &mut T`

[src]

Mutably borrows from an owned value. Read more

###

`impl<T, U> TryInto for T where U: TryFrom<T>,`

[src]

#### `type Error = <U as TryFrom<T>>::Error`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Any for T where T: 'static + ?Sized,`

[src]

####

`fn get_type_id(&self) -> TypeId`

[src]

🔬 This is a nightly-only experimental API. (`get_type_id`)

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

###

`impl<T> Erased for T`

###

`impl<Q, K> Equivalent for Q where K: Borrow<Q> + ?Sized, Q: Eq + ?Sized,`

[src]

####

`fn equivalent(&self, key: &K) -> bool`

[src]

Compare self to `key` and return `true` if they are equal.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)