pub struct LangString { /* private fields */ }
Expand description
Language string.
A language string is a string tagged with language and reading direction information.
A valid language string is associated to either a language tag or a direction, or both.
Implementations§
Source§impl LangString
impl LangString
Sourcepub fn new(
data: SmallString<[u8; 16]>,
language: Option<LenientLangTagBuf>,
direction: Option<Direction>,
) -> Result<LangString, SmallString<[u8; 16]>>
pub fn new( data: SmallString<[u8; 16]>, language: Option<LenientLangTagBuf>, direction: Option<Direction>, ) -> Result<LangString, SmallString<[u8; 16]>>
Create a new language string.
pub fn into_parts( self, ) -> (SmallString<[u8; 16]>, Option<LenientLangTagBuf>, Option<Direction>)
pub fn parts(&self) -> (&str, Option<&LenientLangTagBuf>, Option<&Direction>)
Sourcepub fn language(&self) -> Option<&LenientLangTag>
pub fn language(&self) -> Option<&LenientLangTag>
Gets the associated language tag, if any.
Sourcepub fn set_language(
&mut self,
language: Option<LenientLangTagBuf>,
) -> Result<(), InvalidLangString>
pub fn set_language( &mut self, language: Option<LenientLangTagBuf>, ) -> Result<(), InvalidLangString>
Sets the associated language tag.
If None
is given, the direction must be set,
otherwise this function will fail with an InvalidLangString
error.
Sourcepub fn set_direction(
&mut self,
direction: Option<Direction>,
) -> Result<(), InvalidLangString>
pub fn set_direction( &mut self, direction: Option<Direction>, ) -> Result<(), InvalidLangString>
Sets the associated direction.
If None
is given, a language tag must be set,
otherwise this function will fail with an InvalidLangString
error.
Sourcepub fn set(
&mut self,
language: Option<LenientLangTagBuf>,
direction: Option<Direction>,
) -> Result<(), InvalidLangString>
pub fn set( &mut self, language: Option<LenientLangTagBuf>, direction: Option<Direction>, ) -> Result<(), InvalidLangString>
Set both the language tag and direction.
If both language
and direction
are None
,
this function will fail with an InvalidLangString
error.
Sourcepub fn as_lang_str(&self) -> LangStr<'_>
pub fn as_lang_str(&self) -> LangStr<'_>
Returns a reference to this lang string as a LangStr
.
Trait Implementations§
Source§impl Clone for LangString
impl Clone for LangString
Source§fn clone(&self) -> LangString
fn clone(&self) -> LangString
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LangString
impl Debug for LangString
Source§impl<'de> Deserialize<'de> for LangString
impl<'de> Deserialize<'de> for LangString
Source§fn deserialize<D>(
deserializer: D,
) -> Result<LangString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<LangString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for LangString
impl Hash for LangString
Source§impl Ord for LangString
impl Ord for LangString
Source§fn cmp(&self, other: &LangString) -> Ordering
fn cmp(&self, other: &LangString) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for LangString
impl PartialEq for LangString
Source§impl PartialOrd for LangString
impl PartialOrd for LangString
Source§impl Serialize for LangString
impl Serialize for LangString
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for LangString
impl StructuralPartialEq for LangString
Auto Trait Implementations§
impl Freeze for LangString
impl RefUnwindSafe for LangString
impl Send for LangString
impl Sync for LangString
impl Unpin for LangString
impl UnwindSafe for LangString
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
Mutably borrows from an owned value. Read more
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.