[][src]Enum elefren::Language

pub enum Language {
    // some variants omitted
}

Methods

impl Language[src]

pub fn to_639_3(&self) -> &'static str[src]

Create string representation of this Language as a ISO 639-3 code.

This method will return the ISO 639-3 code, which consists of three letters.

Example

use isolang::Language;

assert_eq!(Language::Deu.to_639_3(), "deu");

pub fn to_639_1(&self) -> Option<&'static str>[src]

Create two-letter ISO 639-1 representation of the language.

This will return a two-letter ISO 639-1 code, if it exists and None otherwise. ISO 639-1 codes are only used for the most common languages.

Example

use isolang::Language;

assert!(Language::Gha.to_639_1().is_none());

pub fn to_name(&self) -> &'static str[src]

Get the English name of this language.

This returns the English name of the language, as defined in the ISO 639 standard. It does not include additional comments, e.g. classification of a macrolanguage, etc.

Examples

use isolang::Language;

assert_eq!(Language::Spa.to_name(), "Spanish");
// macro language
assert_eq!(Language::Swa.to_name(), "Swahili");
// individual language
assert_eq!(Language::Swh.to_name(), "Swahili");

pub fn from_639_1(code: &str) -> Option<Language>[src]

Create a Language instance rom a ISO 639-1 code.

This will return a Language instance if the given string is a valid two-letter language code. For invalid inputs, None is returned.

Example

use isolang::Language;

assert!(Language::from_639_1("de").is_some());
assert!(Language::from_639_1("…").is_none());

pub fn from_639_3(code: &str) -> Option<Language>[src]

Create a Language instance rom a ISO 639-3 code.

This will return a Language instance if the given string is a valid three-letter language code. For invalid inputs, None is returned.

Example

use isolang::Language;

assert!(Language::from_639_3("dan").is_some());
assert!(Language::from_639_1("…").is_none());

pub fn from_locale(locale: &str) -> Option<Language>[src]

Parse language from given locale

This parses a language from a given locale string, as used by UNIX-alike and other systems.

Example

use isolang::Language;

fn main() {
    assert!(Language::from_locale("de_DE.UTF-8") == Some(Language::Deu));
}

Trait Implementations

impl Copy for Language[src]

impl Clone for Language[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Language[src]

impl PartialEq<Language> for Language[src]

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

This method tests for !=.

impl Serialize for Language[src]

impl Hash for Language[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Eq for Language[src]

impl Display for Language[src]

impl<'de> Deserialize<'de> for Language[src]

impl Debug for Language[src]

Auto Trait Implementations

impl Send for Language

impl Sync for Language

Blanket Implementations

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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.

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

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

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

impl<T> Erased for T

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

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