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§
source§impl<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>(&mut self, f: F)where
F: FnOnce(Option<T>) -> Option<T>,
pub fn map_literal_type<F>(&mut self, f: F)where
F: FnOnce(Option<T>) -> Option<T>,
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> ⓘ
sourcepub fn canonicalize_with(&mut self, buffer: &mut Buffer)
pub fn canonicalize_with(&mut self, buffer: &mut Buffer)
Puts this value object literal into canonical form using the given
buffer
.
The buffer is used to compute the canonical form of numbers.
sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Puts this literal into canonical form.
Trait Implementations§
source§impl<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<'a>>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
source§impl<T, M, N> IntoJsonWithContextMeta<M, N> for Value<T, M>where
M: Clone,
N: IriVocabulary<Iri = T>,
impl<T, M, N> IntoJsonWithContextMeta<M, N> for Value<T, M>where
M: Clone,
N: IriVocabulary<Iri = T>,
source§impl<T, M> Ord for Value<T, M>where
T: Ord,
M: Ord,
impl<T, M> Ord for Value<T, M>where
T: Ord,
M: Ord,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T, M> PartialEq<Value<T, M>> for Value<T, M>where
T: PartialEq<T>,
M: PartialEq<M>,
impl<T, M> PartialEq<Value<T, M>> for Value<T, M>where
T: PartialEq<T>,
M: PartialEq<M>,
source§impl<T, M> PartialOrd<Value<T, M>> for Value<T, M>where
T: PartialOrd<T>,
M: PartialOrd<M>,
impl<T, M> PartialOrd<Value<T, M>> for Value<T, M>where
T: PartialOrd<T>,
M: PartialOrd<M>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, M> StrippedHash for Value<T, M>where
T: Hash,
impl<T, M> StrippedHash for Value<T, M>where
T: Hash,
fn stripped_hash<H>(&self, state: &mut H)where
H: Hasher,
source§impl<T, M> StrippedOrd for Value<T, M>where
T: Ord,
impl<T, M> StrippedOrd for Value<T, M>where
T: Ord,
fn stripped_cmp(&self, other: &Value<T, M>) -> Ordering
source§impl<T, M, __M> StrippedPartialEq<Value<T, __M>> for Value<T, M>where
T: PartialEq<T>,
impl<T, M, __M> StrippedPartialEq<Value<T, __M>> for Value<T, M>where
T: PartialEq<T>,
fn stripped_eq(&self, other: &Value<T, __M>) -> bool
source§impl<T, M, __M> StrippedPartialOrd<Value<T, __M>> for Value<T, M>where
T: PartialOrd<T>,
impl<T, M, __M> StrippedPartialOrd<Value<T, __M>> for Value<T, M>where
T: PartialOrd<T>,
impl<T, M> Eq for Value<T, M>where
T: Eq,
M: Eq,
impl<T, M> StrippedEq for Value<T, M>where
T: Eq,
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§
source§impl<I, B, M, T> CompactIndexedFragment<I, B, M> for Twhere
T: Any<I, B, M>,
impl<I, B, M, T> CompactIndexedFragment<I, B, M> for Twhere
T: Any<I, B, M>,
fn compact_indexed_fragment<N, C, L, 'a>(
&'a self,
vocabulary: &'a mut N,
meta: &'a M,
index: Option<&'a Entry<String, M>>,
active_context: &'a Context<I, B, C, M>,
type_scoped_context: &'a Context<I, B, C, M>,
active_property: Option<Meta<&'a str, &'a M>>,
loader: &'a mut L,
options: Options
) -> Pin<Box<dyn Future<Output = Result<Meta<Value<M>, M>, Meta<Error<<L as ContextLoader<I, M>>::ContextError>, M>>> + Send + 'a, Global>>where
L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
I: Clone + Hash + Eq + Send + Sync,
B: Clone + Hash + Eq + Send + Sync,
M: Clone + Send + Sync,
C: ProcessMeta<I, B, M>,
<L as ContextLoader<I, M>>::Context: Into<C>,
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
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
key
and return true
if they are equal.