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
impl ULoc
Sourcepub fn canonicalize(&self) -> Result<ULoc, Error>
pub fn canonicalize(&self) -> Result<ULoc, Error>
Implements uloc_canonicalize
from ICU4C.
Sourcepub fn iso3_language(&self) -> Option<String>
pub fn iso3_language(&self) -> Option<String>
Implements ‘uloc_getISO3Language’ from ICU4C.
Sourcepub fn iso3_country(&self) -> Option<String>
pub fn iso3_country(&self) -> Option<String>
Implements ‘uloc_getISO3Country’ from ICU4C.
Sourcepub fn display_language(&self, display_locale: &ULoc) -> Result<UChar, Error>
pub fn display_language(&self, display_locale: &ULoc) -> Result<UChar, Error>
Implements uloc_getDisplayLanguage
.
Sourcepub fn display_script(&self, display_locale: &ULoc) -> Result<UChar, Error>
pub fn display_script(&self, display_locale: &ULoc) -> Result<UChar, Error>
Implements uloc_getDisplayScript
.
Sourcepub fn display_country(&self, display_locale: &ULoc) -> Result<UChar, Error>
pub fn display_country(&self, display_locale: &ULoc) -> Result<UChar, Error>
Implements uloc_getDisplayCountry
.
Sourcepub fn display_variant(&self, display_locale: &ULoc) -> Result<UChar, Error>
pub fn display_variant(&self, display_locale: &ULoc) -> Result<UChar, Error>
Implements uloc_getDisplayVariant
.
Sourcepub fn display_keyword(
keyword: &String,
display_locale: &ULoc,
) -> Result<UChar, Error>
pub fn display_keyword( keyword: &String, display_locale: &ULoc, ) -> Result<UChar, Error>
Implements uloc_getDisplayKeyword
.
Sourcepub fn display_keyword_value(
&self,
keyword: &String,
display_locale: &ULoc,
) -> Result<UChar, Error>
pub fn display_keyword_value( &self, keyword: &String, display_locale: &ULoc, ) -> Result<UChar, Error>
Implements uloc_getDisplayKeywordValue
.
Sourcepub fn display_name(&self, display_locale: &ULoc) -> Result<UChar, Error>
pub fn display_name(&self, display_locale: &ULoc) -> Result<UChar, Error>
Implements uloc_getDisplayName
.
Sourcepub fn count_available() -> i32
pub fn count_available() -> i32
Implements uloc_countAvailable
.
Sourcepub fn get_available_locales() -> Vec<ULoc>
pub fn get_available_locales() -> Vec<ULoc>
Returns a vector of available locales
Sourcepub fn open_available_by_type(
locale_type: ULocAvailableType,
) -> Result<Enumeration, Error>
pub fn open_available_by_type( locale_type: ULocAvailableType, ) -> Result<Enumeration, Error>
Implements uloc_openAvailableByType
.
Sourcepub fn get_available_locales_by_type(
locale_type: ULocAvailableType,
) -> Vec<ULoc>
pub fn get_available_locales_by_type( locale_type: ULocAvailableType, ) -> Vec<ULoc>
Returns a vector of locales of the requested type.
Implements uloc_addLikelySubtags
from ICU4C.
Implements uloc_minimizeSubtags
from ICU4C.
Sourcepub fn to_language_tag(&self, strict: bool) -> Result<String, Error>
pub fn to_language_tag(&self, strict: bool) -> Result<String, Error>
Implements uloc_toLanguageTag
from ICU4C.
pub fn open_keywords(&self) -> Result<Enumeration, Error>
Sourcepub fn keywords(&self) -> impl Iterator<Item = String>
pub fn keywords(&self) -> impl Iterator<Item = String>
Implements uloc_openKeywords()
from ICU4C.
Sourcepub fn unicode_keywords(&self) -> impl Iterator<Item = String>
pub fn unicode_keywords(&self) -> impl Iterator<Item = String>
Implements icu::Locale::getUnicodeKeywords()
from the C++ API.
Sourcepub fn keyword_value(&self, keyword: &str) -> Result<Option<String>, Error>
pub fn keyword_value(&self, keyword: &str) -> Result<Option<String>, Error>
Implements uloc_getKeywordValue()
from ICU4C.
Sourcepub fn unicode_keyword_value(
&self,
unicode_keyword: &str,
) -> Result<Option<String>, Error>
pub fn unicode_keyword_value( &self, unicode_keyword: &str, ) -> Result<Option<String>, Error>
Implements icu::Locale::getUnicodeKeywordValue()
from the C++ API.
Trait Implementations§
Source§impl Display for ULoc
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§impl Ord for ULoc
impl Ord for ULoc
This implementation is based on ULocale.compareTo from ICU4J. See https://github.com/unicode-org/icu/blob/%6d%61%73%74%65%72/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
Source§impl PartialOrd for ULoc
impl PartialOrd for ULoc
impl Eq for ULoc
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)