[−][src]Struct unic_locale_impl::extensions::TransformExtensionList
A list of Unicode BCP47 T Extensions as defined in Unicode Locale Identifier specification.
Transform extension carries information about source language or script of
transformed content, including content that has been transliterated, transcribed,
or translated, or in some other way influenced by the source (See RFC 6497 for details).
Examples
use unic_locale_impl::{Locale, LanguageIdentifier}; let mut loc: Locale = "de-t-en-US-h0-hybrid".parse() .expect("Parsing failed."); let en_us: LanguageIdentifier = "en-US".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.transform.get_tlang(), Some(&en_us)); assert_eq!( loc.extensions.transform.get_tfield("h0") .expect("Getting tfield failed.") .collect::<Vec<_>>(), &["hybrid"] );
Methods
impl TransformExtensionList[src]
pub fn is_empty(&self) -> bool[src]
Returns true if there are no tfields and no tlang in
the TransformExtensionList.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-t-es-AR".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.transform.is_empty(), false);
pub fn get_tlang(&self) -> Option<&LanguageIdentifier>[src]
Gets tlang from the TransformExtensionList.
Examples
use unic_locale_impl::Locale; use unic_langid_impl::LanguageIdentifier; let mut loc: Locale = "en-US-t-es-AR".parse() .expect("Parsing failed."); let tlang: LanguageIdentifier = "es-AR".parse() .expect("Parsing failed on tlang."); assert_eq!(loc.extensions.transform.get_tlang(), Some(&tlang));
pub fn set_tlang(
&mut self,
tlang: LanguageIdentifier
) -> Result<(), LocaleError>[src]
&mut self,
tlang: LanguageIdentifier
) -> Result<(), LocaleError>
Sets tlang on the TransformExtensionList.
Examples
use unic_locale_impl::Locale; use unic_langid_impl::LanguageIdentifier; let mut loc: Locale = "en-US".parse() .expect("Parsing failed."); let tlang: LanguageIdentifier = "es-AR".parse() .expect("Parsing failed on tlang."); loc.extensions.transform.set_tlang(tlang) .expect("Setting tlang failed."); assert_eq!(loc.to_string(), "en-US-t-es-AR");
pub fn clear_tlang(&mut self)[src]
Clears tlang on the TransformExtensionList.
Examples
use unic_locale_impl::Locale; use unic_langid_impl::LanguageIdentifier; let mut loc: Locale = "en-US-t-es-AR".parse() .expect("Parsing failed."); loc.extensions.transform.clear_tlang(); assert_eq!(loc.to_string(), "en-US");
pub fn get_tfield<S: AsRef<[u8]>>(
&self,
tkey: S
) -> Result<impl ExactSizeIterator<Item = &str>, LocaleError>[src]
&self,
tkey: S
) -> Result<impl ExactSizeIterator<Item = &str>, LocaleError>
Returns the tvalue of tfield in the TransformExtensionList.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-t-k0-dvorak".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.transform.get_tfield("k0") .expect("Getting tfield failed.") .collect::<Vec<_>>(), &["dvorak"]); // Here tfield with tkey "m0" is not available assert_eq!(loc.extensions.transform.get_tfield("m0") .expect("Getting tfield failed.") .collect::<Vec<_>>() .is_empty(), true);
pub fn get_tfield_keys(&self) -> impl ExactSizeIterator<Item = &str>[src]
Returns an iterator over all tkeys in the TransformExtensionList.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-t-k0-dvorak-h0-hybrid".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.transform.get_tfield_keys().collect::<Vec<_>>(), &["h0", "k0"]);
pub fn set_tfield<S: AsRef<[u8]>>(
&mut self,
tkey: S,
tvalue: &[S]
) -> Result<(), LocaleError>[src]
&mut self,
tkey: S,
tvalue: &[S]
) -> Result<(), LocaleError>
Adds a tfield to the TransformExtensionList or sets tvalue for tkey if
tfield is already included in the TransformExtensionList.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US".parse() .expect("Parsing failed."); loc.extensions.transform.set_tfield("k0", &["dvorak"]) .expect("Setting tfield failed."); assert_eq!(loc.to_string(), "en-US-t-k0-dvorak"); loc.extensions.transform.set_tfield("k0", &["colemak"]) .expect("Setting tfield failed."); assert_eq!(loc.to_string(), "en-US-t-k0-colemak");
pub fn remove_tfield<S: AsRef<[u8]>>(
&mut self,
tkey: S
) -> Result<bool, LocaleError>[src]
&mut self,
tkey: S
) -> Result<bool, LocaleError>
Removes a tfield from the TransformExtensionList.
Returns true if tfield was included in the TransformExtensionList
before removal.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-t-k0-dvorak".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.transform.remove_tfield("k0") .expect("Removing tfield failed."), true); assert_eq!(loc.to_string(), "en-US");
pub fn clear_tfields(&mut self)[src]
Clears all tfields from the TransformExtensionList.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-t-k0-dvorak".parse() .expect("Parsing failed."); loc.extensions.transform.clear_tfields(); assert_eq!(loc.to_string(), "en-US");
Trait Implementations
impl Clone for TransformExtensionList[src]
fn clone(&self) -> TransformExtensionList[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Default for TransformExtensionList[src]
fn default() -> TransformExtensionList[src]
impl Eq for TransformExtensionList[src]
impl PartialEq<TransformExtensionList> for TransformExtensionList[src]
fn eq(&self, other: &TransformExtensionList) -> bool[src]
fn ne(&self, other: &TransformExtensionList) -> bool[src]
impl Display for TransformExtensionList[src]
impl Debug for TransformExtensionList[src]
impl Hash for TransformExtensionList[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl StructuralPartialEq for TransformExtensionList[src]
impl StructuralEq for TransformExtensionList[src]
Auto Trait Implementations
impl Send for TransformExtensionList
impl Sync for TransformExtensionList
impl Unpin for TransformExtensionList
impl UnwindSafe for TransformExtensionList
impl RefUnwindSafe for TransformExtensionList
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,