Struct json_ld_core::LangString
source · 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
sourceimpl LangString
impl LangString
sourcepub fn new(
data: LiteralString,
language: Option<LenientLanguageTagBuf>,
direction: Option<Direction>
) -> Result<Self, LiteralString>
pub fn new(
data: LiteralString,
language: Option<LenientLanguageTagBuf>,
direction: Option<Direction>
) -> Result<Self, LiteralString>
Create a new language string.
pub fn into_parts(
self
) -> (LiteralString, Option<LenientLanguageTagBuf>, Option<Direction>)
pub fn parts(
&self
) -> (&str, Option<&LenientLanguageTagBuf>, Option<&Direction>)
sourcepub fn language(&self) -> Option<LenientLanguageTag<'_>>
pub fn language(&self) -> Option<LenientLanguageTag<'_>>
Gets the associated language tag, if any.
sourcepub fn set_language(
&mut self,
language: Option<LenientLanguageTagBuf>
) -> Result<(), InvalidLangString>
pub fn set_language(
&mut self,
language: Option<LenientLanguageTagBuf>
) -> 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<LenientLanguageTagBuf>,
direction: Option<Direction>
) -> Result<(), InvalidLangString>
pub fn set(
&mut self,
language: Option<LenientLanguageTagBuf>,
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.
Trait Implementations
sourceimpl Clone for LangString
impl Clone for LangString
sourcefn clone(&self) -> LangString
fn clone(&self) -> LangString
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for LangString
impl Debug for LangString
sourceimpl Hash for LangString
impl Hash for LangString
sourceimpl Ord for LangString
impl Ord for LangString
sourcefn cmp(&self, other: &LangString) -> Ordering
fn cmp(&self, other: &LangString) -> Ordering
1.21.0 · sourcefn 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
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<LangString> for LangString
impl PartialEq<LangString> for LangString
sourcefn eq(&self, other: &LangString) -> bool
fn eq(&self, other: &LangString) -> bool
sourceimpl PartialOrd<LangString> for LangString
impl PartialOrd<LangString> for LangString
sourcefn partial_cmp(&self, other: &LangString) -> Option<Ordering>
fn partial_cmp(&self, other: &LangString) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
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 moreimpl Eq for LangString
impl StructuralEq for LangString
impl StructuralPartialEq for LangString
Auto Trait Implementations
impl RefUnwindSafe for LangString
impl Send for LangString
impl Sync for LangString
impl Unpin for LangString
impl UnwindSafe for LangString
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> BorrowStripped for T
impl<T> BorrowStripped for T
sourceimpl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.