[][src]Struct langtag::LangTag

pub struct LangTag<T> { /* fields omitted */ }

Normal language subtag.

The language subtag can be modified when the internal buffer type (T) is Vec<u8>.

Implementations

impl<'a> LangTag<&'a [u8]>[src]

pub fn parse<T: AsRef<[u8]> + ?Sized>(
    bytes: &'a T
) -> Result<LangTag<&'a [u8]>, Error>
[src]

Parse a normal language tag.

impl LangTag<Vec<u8>>[src]

pub fn parse_copy<T: AsRef<[u8]> + ?Sized>(
    bytes: &T
) -> Result<LangTag<Vec<u8>>, Error>
[src]

Parse and copy a normal language tag.

The returned normal language tag owns its buffer.

impl<T: AsRef<[u8]>> LangTag<T>[src]

pub fn new(data: T) -> Result<LangTag<T>, Error>[src]

Create a new normal language tag by parsing and using the given buffer.

pub fn into_raw_parts(self) -> (T, ParsedLangTag)[src]

Consume the tag and returns its internal buffer along with the parsing metadata.

pub unsafe fn from_raw_parts(data: T, p: ParsedLangTag) -> LangTag<T>[src]

Create a new normal language tag using p as parsing metadata.

Safety

The input data is not checked for well-formedness, which must be ensred by the caller.

pub fn inner(&self) -> &T[src]

Returns a reference to the tag's buffer.

pub fn parsing_data(&self) -> ParsedLangTag[src]

Returns a copy of the parsing metadata.

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

Returns the bytes representation of the tag.

pub fn as_str(&self) -> &str[src]

Returns the string representation of the tag.

pub fn language(&self) -> &Language[src]

Get the language subtags.

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

Get the script subtag, if any.

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

Get the region subtag, if any.

pub fn variants(&self) -> &Variants[src]

Get the variant subtags.

pub fn extensions(&self) -> &Extensions[src]

Get the extension subtags.

pub fn private_use_subtags(&self) -> &PrivateUseSubtags[src]

Get the private use subtags.

impl<T: AsMut<Vec<u8>>> LangTag<T>[src]

pub fn language_mut(&mut self) -> LanguageMut<'_>[src]

Get and modify the language subtags.

pub fn set_language(&mut self, lang: &Language)[src]

Set the language subtags.

pub fn set_script(&mut self, script: Option<&Script>)[src]

Set the script subtag.

pub fn set_region(&mut self, region: Option<&Region>)[src]

Set the region subtag.

pub fn variants_mut(&mut self) -> VariantsMut<'_>[src]

Get and modify the variant subtags.

pub fn extensions_mut(&mut self) -> ExtensionsMut<'_>[src]

Get and modify the extension subtags.

pub fn private_use_subtags_mut(&mut self) -> PrivateUseSubtagsMut<'_>[src]

Get and modify the private use subtags.

Trait Implementations

impl<T: Clone> Clone for LangTag<T>[src]

impl<T: AsRef<[u8]>> Debug for LangTag<T>[src]

impl<T: AsRef<[u8]>> Display for LangTag<T>[src]

impl<T: AsRef<[u8]>> Eq for LangTag<T>[src]

impl<T: AsRef<[u8]>> Hash for LangTag<T>[src]

impl<T: AsRef<[u8]>, U: AsRef<[u8]>> PartialEq<LangTag<U>> for LangTag<T>[src]

impl<T: AsRef<[u8]>, U: AsRef<[u8]> + ?Sized> PartialEq<U> for LangTag<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for LangTag<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for LangTag<T> where
    T: Send
[src]

impl<T> Sync for LangTag<T> where
    T: Sync
[src]

impl<T> Unpin for LangTag<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for LangTag<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.