pub enum Value<T = IriBuf, M = ()> {
Literal(Literal, Option<T>),
LangString(LangString),
Json(Meta<Value<M>, M>),
}
Expand description
Value object.
Either a typed literal value, or an internationalized language string.
Variants
Literal(Literal, Option<T>)
Typed literal value.
LangString(LangString)
Language tagged string.
Json(Meta<Value<M>, M>)
JSON literal value.
Implementations
sourceimpl<T, M> Value<T, M>
impl<T, M> Value<T, M>
pub fn as_str(&self) -> Option<&str>
pub fn as_literal(&self) -> Option<(&Literal, Option<&T>)>
pub fn literal_type(&self) -> Option<&T>
sourcepub fn set_literal_type(&mut self, ty: Option<T>) -> Option<T>
pub fn set_literal_type(&mut self, ty: Option<T>) -> Option<T>
Set the literal value type, and returns the old type.
Has no effect and return None
if the value is not a literal value.
sourcepub fn map_literal_type<F: FnOnce(Option<T>) -> Option<T>>(&mut self, f: F)
pub fn map_literal_type<F: FnOnce(Option<T>) -> Option<T>>(&mut self, f: F)
Maps the literal value type.
Has no effect if the value is not a literal value.
pub fn as_bool(&self) -> Option<bool>
pub fn as_number(&self) -> Option<&Number>
sourcepub fn typ(&self) -> Option<TypeRef<'_, T>>
pub fn typ(&self) -> Option<TypeRef<'_, T>>
Return the type of the value if any.
This will return Some(Type::Json)
for JSON literal values.
sourcepub fn language(&self) -> Option<LenientLanguageTag<'_>>
pub fn language(&self) -> Option<LenientLanguageTag<'_>>
If the value is a language tagged string, return its associated language if any.
Returns None
if the value is not a language tagged string.
sourcepub fn direction(&self) -> Option<Direction>
pub fn direction(&self) -> Option<Direction>
If the value is a language tagged string, return its associated direction if any.
Returns None
if the value is not a language tagged string.
pub fn entries(&self) -> Entries<'_, T, M>ⓘNotable traits for Entries<'a, T, M>impl<'a, T, M> Iterator for Entries<'a, T, M> type Item = EntryRef<'a, T, M>;
Trait Implementations
sourceimpl<T, B, M> Any<T, B, M> for Value<T, M>
impl<T, B, M> Any<T, B, M> for Value<T, M>
fn as_ref(&self) -> Ref<'_, T, B, M>
fn id_entry<'a>(&'a self) -> Option<&'a Entry<Id<T, B>, M>>where
M: 'a,
fn id<'a>(&'a self) -> Option<&'a Meta<Id<T, B>, M>>where
M: 'a,
fn language<'a>(&'a self) -> Option<LenientLanguageTag<'_>>where
T: 'a,
B: 'a,
M: 'a,
fn is_value(&self) -> bool
fn is_node(&self) -> bool
fn is_graph(&self) -> bool
fn is_list(&self) -> bool
sourceimpl<T, M: Clone, N: IriVocabulary<Iri = T>> IntoJsonWithContextMeta<M, N> for Value<T, M>
impl<T, M: Clone, N: IriVocabulary<Iri = T>> IntoJsonWithContextMeta<M, N> for Value<T, M>
fn into_json_meta_with(self, meta: M, vocabulary: &N) -> Meta<Value<M>, M>
sourceimpl<T: Ord, M: Ord> Ord for Value<T, M>
impl<T: Ord, M: Ord> Ord for Value<T, M>
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq, M: PartialEq> PartialEq<Value<T, M>> for Value<T, M>
impl<T: PartialEq, M: PartialEq> PartialEq<Value<T, M>> for Value<T, M>
sourceimpl<T: PartialOrd, M: PartialOrd> PartialOrd<Value<T, M>> for Value<T, M>
impl<T: PartialOrd, M: PartialOrd> PartialOrd<Value<T, M>> for Value<T, M>
sourcefn partial_cmp(&self, other: &Value<T, M>) -> Option<Ordering>
fn partial_cmp(&self, other: &Value<T, M>) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moresourceimpl<T: Hash, M> StrippedHash for Value<T, M>
impl<T: Hash, M> StrippedHash for Value<T, M>
fn stripped_hash<H: Hasher>(&self, state: &mut H)
sourceimpl<T: Ord, M> StrippedOrd for Value<T, M>
impl<T: Ord, M> StrippedOrd for Value<T, M>
fn stripped_cmp(&self, other: &Self) -> Ordering
sourceimpl<T: PartialEq, M> StrippedPartialEq<Value<T, M>> for Value<T, M>
impl<T: PartialEq, M> StrippedPartialEq<Value<T, M>> for Value<T, M>
fn stripped_eq(&self, other: &Self) -> bool
sourceimpl<T: PartialOrd, M> StrippedPartialOrd<Value<T, M>> for Value<T, M>
impl<T: PartialOrd, M> StrippedPartialOrd<Value<T, M>> for Value<T, M>
fn stripped_partial_cmp(&self, other: &Self) -> Option<Ordering>
impl<T: Eq, M: Eq> Eq for Value<T, M>
impl<T: Eq, M> StrippedEq for Value<T, M>
impl<T, M> StructuralEq for Value<T, M>
impl<T, M> StructuralPartialEq for Value<T, M>
Auto Trait Implementations
impl<T, M> RefUnwindSafe for Value<T, M>where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M> Send for Value<T, M>where
M: Send,
T: Send,
impl<T, M> Sync for Value<T, M>where
M: Sync,
T: Sync,
impl<T, M> Unpin for Value<T, M>where
M: Unpin,
T: Unpin,
impl<T, M> UnwindSafe for Value<T, M>where
M: UnwindSafe,
T: UnwindSafe,
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.