Skip to main content

LangTag

Struct LangTag 

Source
pub struct LangTag(/* private fields */);
Expand description

Any language tag (normal, private use or grandfathered).

Implementations§

Source§

impl LangTag

Source

pub const fn validate_str(input: &str) -> bool

Source

pub const fn validate_bytes(input: &[u8]) -> bool

Source§

impl LangTag

Source

pub fn new<T>(input: &T) -> Result<&LangTag, InvalidLangTag<&T>>
where T: AsRef<[u8]> + ?Sized,

Creates a new langtag by parsing the input value.

Source

pub const fn from_bytes(input: &[u8]) -> Result<&LangTag, InvalidLangTag<&[u8]>>

Creates a new langtag by parsing the input bytes.

Source

pub const fn from_str(input: &str) -> Result<&LangTag, InvalidLangTag<&str>>

Creates a new langtag by parsing the input string.

Source

pub const unsafe fn new_unchecked_from_bytes(input: &[u8]) -> &LangTag

Creates a new langtag from the input bytes without validation.

§Safety

The input bytes must be a valid langtag.

Source

pub const unsafe fn new_unchecked(input: &str) -> &LangTag

Creates a new langtag from the input string without validation.

§Safety

The input string must be a valid langtag.

Source§

impl LangTag

Source

pub const fn as_str(&self) -> &str

Returns the langtag as a string.

Source

pub const fn as_bytes(&self) -> &[u8] ⓘ

Returns the langtag as a byte string.

Source§

impl LangTag

Source

pub fn language(&self) -> Option<&Language>

Returns the language subtags, if any.

Only normal language tags and regular grandfathered tags have language subtags.

Source

pub fn script(&self) -> Option<&Script>

Returns the script subtag, if any.

Source

pub fn region(&self) -> Option<&Region>

Returns the region subtag, if any.

Source

pub fn variants(&self) -> &Variants

Returns the variant subtags, if any.

Source

pub fn extensions(&self) -> &Extensions

Returns the extension subtags, if any.

Source

pub fn private_use(&self) -> Option<&PrivateUse>

Returns the private use subtag, if any.

Source

pub fn private_use_subtags(&self) -> PrivateUseIter<'_> ⓘ

Returns an iterator over the private use subtag subtags.

Source

pub fn is_normal(&self) -> bool

Returns wether or not this language tag is a normal language tag.

Source

pub fn is_private_use(&self) -> bool

Returns wether or not this language tag is a private use tag.

Source

pub fn is_grandfathered(&self) -> bool

Returns wether or not this language tag is a grandfathered tag.

Source

pub fn as_normal(&self) -> Option<&NormalLangTag>

Returns this language tag as a normal tag, if it is one.

Source

pub fn as_private_use(&self) -> Option<&PrivateUse>

Returns this language tag as a private use tag, if it is one.

Source

pub fn as_grandfathered(&self) -> Option<GrandfatheredLangTag>

Returns this language tag as a grandfathered tag, if it is one.

Source

pub fn kind(&self) -> Kind

Returns the kind of the tag (normal, private use or grandfathered).

Source

pub fn as_typed(&self) -> TypedLangTag<'_>

Find out what kind of language tag self is.

Trait Implementations§

Source§

impl AsRef<LangTag> for LangTag

Source§

fn as_ref(&self) -> &LangTag

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<LangTag> for LangTagBuf

Source§

fn as_ref(&self) -> &LangTag

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for LangTag

Source§

fn as_ref(&self) -> &[u8] ⓘ

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for LangTag

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<LangTag> for LangTagBuf

Source§

fn borrow(&self) -> &LangTag

Immutably borrows from an owned value. Read more
Source§

impl Borrow<str> for LangTag

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl Debug for LangTag

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for LangTag

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for LangTag

Source§

impl Hash for LangTag

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl Ord for LangTag

Source§

fn cmp(&self, other: &LangTag) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for LangTag

Source§

fn eq(&self, other: &LangTag) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&LangTag> for LangTagBuf

Source§

fn eq(&self, other: &&LangTag) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&[u8]> for LangTag

Source§

fn eq(&self, other: &&[u8]) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&str> for LangTag

Source§

fn eq(&self, other: &&str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<LangTag> for LangTagBuf

Source§

fn eq(&self, other: &LangTag) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<LangTagBuf> for LangTag

Source§

fn eq(&self, other: &LangTagBuf) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<LangTagBuf> for &LangTag

Source§

fn eq(&self, other: &LangTagBuf) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<String> for LangTag

Source§

fn eq(&self, other: &String) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<Vec<u8>> for LangTag

Source§

fn eq(&self, other: &Vec<u8>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<[u8]> for LangTag

Source§

fn eq(&self, other: &[u8]) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<str> for LangTag

Source§

fn eq(&self, other: &str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for LangTag

Source§

fn partial_cmp(&self, other: &LangTag) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&LangTag> for LangTagBuf

Source§

fn partial_cmp(&self, other: &&LangTag) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&[u8]> for LangTag

Source§

fn partial_cmp(&self, other: &&[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&str> for LangTag

Source§

fn partial_cmp(&self, other: &&str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<LangTag> for LangTagBuf

Source§

fn partial_cmp(&self, other: &LangTag) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<LangTagBuf> for LangTag

Source§

fn partial_cmp(&self, other: &LangTagBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<LangTagBuf> for &LangTag

Source§

fn partial_cmp(&self, other: &LangTagBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<String> for LangTag

Source§

fn partial_cmp(&self, other: &String) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Vec<u8>> for LangTag

Source§

fn partial_cmp(&self, other: &Vec<u8>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<[u8]> for LangTag

Source§

fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<str> for LangTag

Source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RdfDisplay for LangTag

Source§

fn rdf_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
Source§

fn rdf_display(&self) -> RdfDisplayed<&Self>

Prepare the value to be formatted as an RDF syntax element.
Source§

impl ToOwned for LangTag

Source§

type Owned = LangTagBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> <LangTag as ToOwned>::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

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

impl<'a> TryFrom<&'a [u8]> for &'a LangTag

Source§

type Error = InvalidLangTag<&'a [u8]>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a [u8]) -> Result<&'a LangTag, InvalidLangTag<&'a [u8]>>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a str> for &'a LangTag

Source§

type Error = InvalidLangTag<&'a str>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a str) -> Result<&'a LangTag, InvalidLangTag<&'a str>>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

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

Checks if self is equivalent to key.
Source§

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

Source§

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

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

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

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> WithContext for T
where T: ?Sized,

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>
where T: Sized,