Struct json_ld::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§
source§impl LangString
impl LangString
sourcepub fn new(
data: LiteralString,
language: Option<LenientLanguageTagBuf>,
direction: Option<Direction>
) -> Result<LangString, LiteralString>
pub fn new(
data: LiteralString,
language: Option<LenientLanguageTagBuf>,
direction: Option<Direction>
) -> Result<LangString, 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§
source§impl Clone for LangString
impl Clone for LangString
source§fn clone(&self) -> LangString
fn clone(&self) -> LangString
Returns a copy 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 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<LangString> for LangString
impl PartialEq<LangString> for LangString
source§fn eq(&self, other: &LangString) -> bool
fn eq(&self, other: &LangString) -> bool
source§impl PartialOrd<LangString> for LangString
impl PartialOrd<LangString> for LangString
source§fn partial_cmp(&self, other: &LangString) -> Option<Ordering>
fn partial_cmp(&self, other: &LangString) -> Option<Ordering>
1.0.0 · source§fn 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§
source§impl<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
§impl<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
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
source§impl<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,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.