Struct rust_icu_uloc::ULoc

source ·
pub struct ULoc { /* private fields */ }
Expand description

A representation of a Unicode locale.

For the time being, only basic conversion and methods are in fact implemented.

To get basic validation when creating a locale, use for_language_tag with a Unicode BCP-47 locale ID.

Implementations§

source§

impl ULoc

source

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

Implements uloc_getLanguage.

source

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

Implements uloc_getScript.

source

pub fn country(&self) -> Option<String>

Implements uloc_getCountry.

source

pub fn variant(&self) -> Option<String>

Implements uloc_getVariant.

source

pub fn name(&self) -> Option<String>

Implements uloc_getName.

source

pub fn canonicalize(&self) -> Result<ULoc, Error>

Implements uloc_canonicalize from ICU4C.

source

pub fn iso3_language(&self) -> Option<String>

Implements ‘uloc_getISO3Language’ from ICU4C.

source

pub fn iso3_country(&self) -> Option<String>

Implements ‘uloc_getISO3Country’ from ICU4C.

source

pub fn display_language(&self, display_locale: &ULoc) -> Result<UChar, Error>

Implements uloc_getDisplayLanguage.

source

pub fn display_script(&self, display_locale: &ULoc) -> Result<UChar, Error>

Implements uloc_getDisplayScript.

source

pub fn display_country(&self, display_locale: &ULoc) -> Result<UChar, Error>

Implements uloc_getDisplayCountry.

source

pub fn display_variant(&self, display_locale: &ULoc) -> Result<UChar, Error>

Implements uloc_getDisplayVariant.

source

pub fn display_keyword( keyword: &String, display_locale: &ULoc ) -> Result<UChar, Error>

Implements uloc_getDisplayKeyword.

source

pub fn display_keyword_value( &self, keyword: &String, display_locale: &ULoc ) -> Result<UChar, Error>

Implements uloc_getDisplayKeywordValue.

source

pub fn display_name(&self, display_locale: &ULoc) -> Result<UChar, Error>

Implements uloc_getDisplayName.

source

pub fn count_available() -> i32

Implements uloc_countAvailable.

source

pub fn get_available(n: i32) -> Result<ULoc, Error>

Implements uloc_getAvailable.

source

pub fn get_available_locales() -> Vec<ULoc>

Returns a vector of available locales

source

pub fn open_available_by_type( locale_type: ULocAvailableType ) -> Result<Enumeration, Error>

Implements uloc_openAvailableByType.

source

pub fn get_available_locales_by_type( locale_type: ULocAvailableType ) -> Vec<ULoc>

Returns a vector of locales of the requested type.

source

pub fn add_likely_subtags(&self) -> Result<ULoc, Error>

Implements uloc_addLikelySubtags from ICU4C.

source

pub fn minimize_subtags(&self) -> Result<ULoc, Error>

Implements uloc_minimizeSubtags from ICU4C.

source

pub fn to_language_tag(&self, strict: bool) -> Result<String, Error>

Implements uloc_toLanguageTag from ICU4C.

source

pub fn open_keywords(&self) -> Result<Enumeration, Error>

source

pub fn keywords(&self) -> impl Iterator<Item = String>

Implements uloc_openKeywords() from ICU4C.

source

pub fn unicode_keywords(&self) -> impl Iterator<Item = String>

Implements icu::Locale::getUnicodeKeywords() from the C++ API.

source

pub fn keyword_value(&self, keyword: &str) -> Result<Option<String>, Error>

Implements uloc_getKeywordValue() from ICU4C.

source

pub fn unicode_keyword_value( &self, unicode_keyword: &str ) -> Result<Option<String>, Error>

Implements icu::Locale::getUnicodeKeywordValue() from the C++ API.

source

pub fn label(&self) -> &str

Returns the current label of this locale.

source

pub fn as_c_str(&self) -> CString

Returns the current locale name as a C string.

source

pub fn for_language_tag(tag: &str) -> Result<ULoc, Error>

Implements uloc_forLanguageTag from ICU4C.

Note that an invalid tag will cause that tag and all others to be ignored. For example en-us will work but en_US will not.

source

pub fn base_name(self) -> Self

Implements uloc_getBaseName from ICU4C.

Trait Implementations§

source§

impl Clone for ULoc

source§

fn clone(&self) -> ULoc

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ULoc

source§

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

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

impl Display for ULoc

Implement the Display trait to convert the ULoc into string for display.

The string for display and string serialization happen to be the same for ULoc.

source§

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

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

impl From<ULoc> for ULocMut

source§

fn from(l: ULoc) -> Self

Turns ULoc into ULocMut, which can be mutated.

source§

impl From<ULocMut> for ULoc

source§

fn from(lm: ULocMut) -> Self

Converts to this type from the input type.
source§

impl Hash for ULoc

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for ULoc

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for ULoc

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ULoc

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&CStr> for ULoc

source§

fn try_from(s: &CStr) -> Result<Self, Self::Error>

Creates a new ULoc from a borrowed C string.

§

type Error = Error

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

impl TryFrom<&str> for ULoc

source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Creates a new ULoc from a string slice.

The creation wil fail if the locale is nonexistent.

§

type Error = Error

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

impl Eq for ULoc

source§

impl StructuralPartialEq for ULoc

Auto Trait Implementations§

§

impl Freeze for ULoc

§

impl RefUnwindSafe for ULoc

§

impl Send for ULoc

§

impl Sync for ULoc

§

impl Unpin for ULoc

§

impl UnwindSafe for ULoc

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

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

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

source§

default fn to_string(&self) -> String

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.