pub enum Object<T = IriBuf, B = BlankIdBuf> {
Value(Value<T>),
Node(Box<Node<T, B>>),
List(List<T, B>),
}Expand description
Object.
JSON-LD connects together multiple kinds of data objects. Objects may be nodes, values or lists of objects.
You can get an Object by expanding a JSON-LD document using the
expansion algorithm or by converting an already expanded JSON document
using TryFromJson.
Variants§
Implementations§
Source§impl<T, B> Object<T, B>
impl<T, B> Object<T, B>
Sourcepub fn identify_all_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>(
&mut self,
vocabulary: &mut V,
generator: &mut G,
) -> Result<(), GeneratedIdError>
pub fn identify_all_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>( &mut self, vocabulary: &mut V, generator: &mut G, ) -> Result<(), GeneratedIdError>
Assigns an identifier to every node included in this object using the given generator.
§Errors
Returns an error when the generator runs out of identifiers.
Sourcepub fn identify_all<G: LocalGenerator>(
&mut self,
generator: &mut G,
) -> Result<(), GeneratedIdError>
pub fn identify_all<G: LocalGenerator>( &mut self, generator: &mut G, ) -> Result<(), GeneratedIdError>
Use the given generator to assign an identifier to all nodes that
don’t have one.
§Errors
Returns an error when the generator runs out of identifiers.
Sourcepub fn canonicalize_with(&mut self, buffer: &mut Buffer)
pub fn canonicalize_with(&mut self, buffer: &mut Buffer)
Puts every literal of the object into canonical form, using the given
buffer to render numbers.
Sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Puts every literal of the object into canonical form.
Sourcepub fn as_iri(&self) -> Option<&T>
pub fn as_iri(&self) -> Option<&T>
Identifier of the object as an IRI.
If the object is a node identified by an IRI, returns this IRI.
Returns None otherwise.
Sourcepub fn as_value_mut(&mut self) -> Option<&mut Value<T>>
pub fn as_value_mut(&mut self) -> Option<&mut Value<T>>
Returns this object as a mutable value, if it is one.
Sourcepub fn into_value(self) -> Option<Value<T>>
pub fn into_value(self) -> Option<Value<T>>
Converts this object into a value, if it is one.
Sourcepub fn as_node_mut(&mut self) -> Option<&mut Node<T, B>>
pub fn as_node_mut(&mut self) -> Option<&mut Node<T, B>>
Returns this object as a mutable node, if it is one.
Sourcepub fn is_graph(&self) -> bool
pub fn is_graph(&self) -> bool
Tests if the object is a graph object (a node with a @graph field).
Sourcepub fn as_list_mut(&mut self) -> Option<&mut List<T, B>>
pub fn as_list_mut(&mut self) -> Option<&mut List<T, B>>
Returns this object as a mutable list, if it is one.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the object as a string.
If the object is a value holding a string, returns that string.
If the object is a node with an identifier, returns the identifier as
a string. Returns None otherwise.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the object as a boolean, if it is a value holding one.
Sourcepub fn as_number(&self) -> Option<&Number>
pub fn as_number(&self) -> Option<&Number>
Returns the object as a number, if it is a value holding one.
Sourcepub fn language(&self) -> Option<&LenientLangTag>
pub fn language(&self) -> Option<&LenientLangTag>
Returns the associated language, if the object is a language-tagged value.
Sourcepub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
pub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
Returns an iterator over all fragments of this object, including the object itself.
Fragments include:
- objects
- key-value pairs,
- keys
- values
Sourcepub fn equivalent(&self, other: &Self) -> bool
pub fn equivalent(&self, other: &Self) -> bool
Equivalence operator.
Equivalence differs from equality for anonymous objects: list objects and anonymous node objects stand for implicit, unlabeled blank nodes, so they are never equivalent to anything.
Trait Implementations§
Source§impl<T, B> Any<T, B> for Object<T, B>
impl<T, B> Any<T, B> for Object<T, B>
Source§fn id(&self) -> Option<&Id<T, B>>
fn id(&self) -> Option<&Id<T, B>>
@id) of the object, if it is a node object
with one.Source§fn language<'a>(&'a self) -> Option<&'a LenientLangTag>where
T: 'a,
B: 'a,
fn language<'a>(&'a self) -> Option<&'a LenientLangTag>where
T: 'a,
B: 'a,
impl<T: Eq + Hash, B: Eq + Hash> Eq for Object<T, B>
Source§impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContext<N> for Object<T, B>
impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContext<N> for Object<T, B>
Source§impl<T, B, I: Interpretation> LinkedData<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedData<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
Source§impl<T, B, I: Interpretation> LinkedDataGraph<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataGraph<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
Source§fn visit_graph<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: GraphVisitor<I>,
fn visit_graph<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: GraphVisitor<I>,
Source§impl<T, B, I: Interpretation> LinkedDataPredicateObjects<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataPredicateObjects<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
Source§fn visit_objects<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: PredicateObjectsVisitor<I>,
fn visit_objects<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: PredicateObjectsVisitor<I>,
Source§impl<T, B, I: Interpretation> LinkedDataResource<I> for Object<T, B>where
T: LinkedDataResource<I>,
B: LinkedDataResource<I>,
impl<T, B, I: Interpretation> LinkedDataResource<I> for Object<T, B>where
T: LinkedDataResource<I>,
B: LinkedDataResource<I>,
Source§fn interpretation(
&self,
interpretation: &mut I,
) -> ResourceInterpretation<'_, I>
fn interpretation( &self, interpretation: &mut I, ) -> ResourceInterpretation<'_, I>
interpretation if required.Source§fn lexical_representation<'a>(
&'a self,
interpretation: &'a mut I,
) -> Option<CowRdfTerm<'a>>where
I: ReverseInterpretation + ReverseLocalInterpretation,
fn lexical_representation<'a>(
&'a self,
interpretation: &'a mut I,
) -> Option<CowRdfTerm<'a>>where
I: ReverseInterpretation + ReverseLocalInterpretation,
Source§fn reference_interpretation(
&self,
interpretation: &mut I,
) -> ResourceInterpretation<'_, I>
fn reference_interpretation( &self, interpretation: &mut I, ) -> ResourceInterpretation<'_, I>
Source§impl<T, B, I: Interpretation> LinkedDataSubject<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataSubject<I> for Object<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
Source§fn visit_subject<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: SubjectVisitor<I>,
fn visit_subject<S>(&self, visitor: S) -> Result<S::Ok, S::Error>where
S: SubjectVisitor<I>,
Source§impl<T, B> Relabel<T, B> for Object<T, B>
impl<T, B> Relabel<T, B> for Object<T, B>
Source§fn relabel_with<N: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>(
&mut self,
vocabulary: &mut N,
generator: &mut G,
relabeling: &mut HashMap<B, ValidId<T, B>>,
) -> Result<(), GeneratedIdError>
fn relabel_with<N: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>( &mut self, vocabulary: &mut N, generator: &mut G, relabeling: &mut HashMap<B, ValidId<T, B>>, ) -> Result<(), GeneratedIdError>
Source§impl<T: Eq + Hash, B: Eq + Hash> TryFromJson<T, B> for Object<T, B>
impl<T: Eq + Hash, B: Eq + Hash> TryFromJson<T, B> for Object<T, B>
Source§fn try_from_json_in(
vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>,
value: Value,
) -> Result<Self, InvalidExpandedJson>
fn try_from_json_in( vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>, value: Value, ) -> Result<Self, InvalidExpandedJson>
Source§impl<T: Eq + Hash, B: Eq + Hash> TryFromJsonObject<T, B> for Object<T, B>
impl<T: Eq + Hash, B: Eq + Hash> TryFromJsonObject<T, B> for Object<T, B>
Source§fn try_from_json_object_in(
vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>,
object: Object,
) -> Result<Self, InvalidExpandedJson>
fn try_from_json_object_in( vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>, object: Object, ) -> Result<Self, InvalidExpandedJson>
Auto Trait Implementations§
impl<T, B> Freeze for Object<T, B>
impl<T, B> RefUnwindSafe for Object<T, B>
impl<T, B> Send for Object<T, B>
impl<T, B> Sync for Object<T, B>
impl<T, B> Unpin for Object<T, B>
impl<T, B> UnsafeUnpin for Object<T, B>
impl<T, B> UnwindSafe for Object<T, B>
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> 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.