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: String,
language: Option<LenientLangTagBuf>,
direction: Option<Direction>,
) -> Result<Self, InvalidLangString>
pub fn new( data: String, language: Option<LenientLangTagBuf>, direction: Option<Direction>, ) -> Result<Self, InvalidLangString>
Sourcepub fn with_language(data: String, language: LenientLangTagBuf) -> Self
pub fn with_language(data: String, language: LenientLangTagBuf) -> Self
Total constructor: build a language string with a known language tag.
Sourcepub fn with_direction(data: String, direction: Direction) -> Self
pub fn with_direction(data: String, direction: Direction) -> Self
Total constructor: build a language string with a known direction.
Sourcepub fn with_language_and_direction(
data: String,
language: LenientLangTagBuf,
direction: Direction,
) -> Self
pub fn with_language_and_direction( data: String, language: LenientLangTagBuf, direction: Direction, ) -> Self
Total constructor: build a language string with both a language tag and a direction.
Sourcepub fn into_parts(
self,
) -> (String, Option<LenientLangTagBuf>, Option<Direction>)
pub fn into_parts( self, ) -> (String, Option<LenientLangTagBuf>, Option<Direction>)
Consumes the language string, returning its string data, language tag and base direction.
Sourcepub fn parts(&self) -> (&str, Option<&LenientLangTagBuf>, Option<&Direction>)
pub fn parts(&self) -> (&str, Option<&LenientLangTagBuf>, Option<&Direction>)
Returns the string data, language tag and base 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<(), MissingLangQualifier>
pub fn set_language( &mut self, language: Option<LenientLangTagBuf>, ) -> Result<(), MissingLangQualifier>
Sets the associated language tag.
If None is given, the direction must be set,
otherwise this function will fail with a MissingLangQualifier error.
§Errors
Returns an error when removing the language would leave a string with a direction but no language, which is not a valid language-tagged string.
Sourcepub fn set_direction(
&mut self,
direction: Option<Direction>,
) -> Result<(), MissingLangQualifier>
pub fn set_direction( &mut self, direction: Option<Direction>, ) -> Result<(), MissingLangQualifier>
Sets the associated direction.
If None is given, a language tag must be set,
otherwise this function will fail with a MissingLangQualifier error.
§Errors
Returns an error when removing the direction would leave a string with neither language nor direction.
Sourcepub fn set(
&mut self,
language: Option<LenientLangTagBuf>,
direction: Option<Direction>,
) -> Result<(), MissingLangQualifier>
pub fn set( &mut self, language: Option<LenientLangTagBuf>, direction: Option<Direction>, ) -> Result<(), MissingLangQualifier>
Set both the language tag and direction.
If both language and direction are None,
this function will fail with a MissingLangQualifier error.
§Errors
Returns an error when neither a language nor a direction is given, which no longer describes a language-tagged string.
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§impl Debug for LangString
impl Debug for LangString
Source§impl<'de> Deserialize<'de> for LangString
Available on crate feature serde only.
impl<'de> Deserialize<'de> for LangString
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for LangString
Source§impl Hash for LangString
impl Hash for LangString
Source§impl Ord for LangString
impl Ord for LangString
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LangString
impl PartialEq for LangString
Source§impl PartialOrd for LangString
impl PartialOrd for LangString
Source§impl Serialize for LangString
Available on crate feature serde only.
impl Serialize for LangString
serde only.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 UnsafeUnpin 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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Unordered reference.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
self is equivalent to key.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
key and return true if they are equal.