pub struct Node<T = IriBuf, B = BlankIdBuf> {
pub id: Option<Id<T, B>>,
pub types: Option<Vec<Id<T, B>>>,
pub graph: Option<Graph<T, B>>,
pub included: Option<Included<T, B>>,
pub properties: Properties<T, B>,
pub reverse_properties: Option<ReverseProperties<T, B>>,
}Expand description
Node object.
A node object represents zero or more properties of a node in the graph serialized by a JSON-LD document.
A node is defined by its identifier (@id field), types, properties and reverse properties.
In addition, a node may represent a graph (@graph field) and include
other nodes (@included field).
Fields§
§id: Option<Id<T, B>>Identifier.
This is the @id field.
types: Option<Vec<Id<T, B>>>Types.
This is the @type field.
graph: Option<Graph<T, B>>Associated graph.
This is the @graph field.
included: Option<Included<T, B>>Included nodes.
This is the @included field.
properties: Properties<T, B>Properties.
Any non-keyword field.
reverse_properties: Option<ReverseProperties<T, B>>Reverse properties.
This is the @reverse field.
Implementations§
Source§impl<T, B> Node<T, B>
impl<T, B> Node<T, B>
Sourcepub fn reverse_properties_mut_or_default(
&mut self,
) -> &mut ReverseProperties<T, B>
pub fn reverse_properties_mut_or_default( &mut self, ) -> &mut ReverseProperties<T, B>
Returns a mutable reference to the reverse properties of the node.
If no @reverse entry is present, one is created.
Sourcepub fn included_mut_or_default(&mut self) -> &mut Included<T, B>
pub fn included_mut_or_default(&mut self) -> &mut Included<T, B>
Returns a mutable reference to the included nodes.
If no @included entry is present, one is created.
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 this node and every other node included in this
one 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>
Assigns an identifier to this node and every other node included in this one using the given generator.
§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 node 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 node into canonical form.
Sourcepub fn as_iri(&self) -> Option<&T>
pub fn as_iri(&self) -> Option<&T>
Returns the node’s identifier as an IRI, if the node has one and it is an IRI.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the node’s identifier as a string slice.
Returns None if the node has no @id field.
Sourcepub fn types(&self) -> &[Id<T, B>]
pub fn types(&self) -> &[Id<T, B>]
Returns the types of the node, or an empty slice if it has no @type
entry.
Sourcepub fn types_mut(&mut self) -> &mut [Id<T, B>]
pub fn types_mut(&mut self) -> &mut [Id<T, B>]
Mutably borrows the types of the node, or an empty slice if it has no
@type entry.
Sourcepub fn types_mut_or_default(&mut self) -> &mut Vec<Id<T, B>>
pub fn types_mut_or_default(&mut self) -> &mut Vec<Id<T, B>>
Mutably borrows the types of this node, inserting an empty list if it has none.
Sourcepub fn types_mut_or_insert(
&mut self,
value: Vec<Id<T, B>>,
) -> &mut Vec<Id<T, B>>
pub fn types_mut_or_insert( &mut self, value: Vec<Id<T, B>>, ) -> &mut Vec<Id<T, B>>
Mutably borrows the types of this node, inserting value if it has
none.
Sourcepub fn types_mut_or_insert_with(
&mut self,
f: impl FnOnce() -> Vec<Id<T, B>>,
) -> &mut Vec<Id<T, B>>
pub fn types_mut_or_insert_with( &mut self, f: impl FnOnce() -> Vec<Id<T, B>>, ) -> &mut Vec<Id<T, B>>
Mutably borrows the types of this node, inserting the result of f if
it has none.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Tests if the node is empty.
It is empty if every field other than @id is empty.
Sourcepub fn is_graph(&self) -> bool
pub fn is_graph(&self) -> bool
Tests if the node is a graph object (has a @graph field, and
optionally an @id field). A node object with a @graph entry is
not considered a graph object if it includes any entry other than
@id.
Sourcepub fn is_simple_graph(&self) -> bool
pub fn is_simple_graph(&self) -> bool
Tests if the node is a simple graph object (a graph object without @id field)
Sourcepub fn graph(&self) -> Option<&Graph<T, B>>
pub fn graph(&self) -> Option<&Graph<T, B>>
Returns the node objects of the @graph entry, if the node has one.
Note that having a @graph entry is necessary but not sufficient for
the node to be a graph object; see is_graph.
Sourcepub fn graph_mut(&mut self) -> Option<&mut Graph<T, B>>
pub fn graph_mut(&mut self) -> Option<&mut Graph<T, B>>
Mutably borrows the node objects of the @graph entry, if the node
has one.
Sourcepub fn graph_entry(&self) -> Option<&Graph<T, B>>
pub fn graph_entry(&self) -> Option<&Graph<T, B>>
Returns the node objects of the @graph entry, if the node has one.
Alias for graph.
Sourcepub fn graph_entry_mut(&mut self) -> Option<&mut Graph<T, B>>
pub fn graph_entry_mut(&mut self) -> Option<&mut Graph<T, B>>
Mutably borrows the node objects of the @graph entry, if the node
has one.
Alias for graph_mut.
Sourcepub fn set_graph_entry(&mut self, graph: Option<Graph<T, B>>)
pub fn set_graph_entry(&mut self, graph: Option<Graph<T, B>>)
Sets the @graph entry of the node, or removes it when given None.
Sourcepub fn included_entry(&self) -> Option<&Included<T, B>>
pub fn included_entry(&self) -> Option<&Included<T, B>>
Returns the set of nodes included by this node.
This corresponds to the @included field in the JSON representation.
Sourcepub fn included_entry_mut(&mut self) -> Option<&mut Included<T, B>>
pub fn included_entry_mut(&mut self) -> Option<&mut Included<T, B>>
Returns the mutable set of nodes included by this node.
This corresponds to the @included field in the JSON representation.
Sourcepub fn included(&self) -> Option<&Included<T, B>>
pub fn included(&self) -> Option<&Included<T, B>>
Returns a reference to the set of @included nodes.
Sourcepub fn included_mut(&mut self) -> Option<&mut Included<T, B>>
pub fn included_mut(&mut self) -> Option<&mut Included<T, B>>
Returns a mutable reference to the set of @included nodes.
Sourcepub fn set_included(&mut self, included: Option<Included<T, B>>)
pub fn set_included(&mut self, included: Option<Included<T, B>>)
Sets the @included entry of the node, or removes it when given
None.
Sourcepub fn properties(&self) -> &Properties<T, B>
pub fn properties(&self) -> &Properties<T, B>
Returns a reference to the properties of the node.
Sourcepub fn properties_mut(&mut self) -> &mut Properties<T, B>
pub fn properties_mut(&mut self) -> &mut Properties<T, B>
Returns a mutable reference to the properties of the node.
Sourcepub fn reverse_properties(&self) -> Option<&ReverseProperties<T, B>>
pub fn reverse_properties(&self) -> Option<&ReverseProperties<T, B>>
Returns a reference to the reverse properties of the node, if it has
a @reverse entry.
Sourcepub fn reverse_properties_entry(&self) -> Option<&ReverseProperties<T, B>>
pub fn reverse_properties_entry(&self) -> Option<&ReverseProperties<T, B>>
Returns a reference to the reverse properties of the node, if it has
a @reverse entry.
Sourcepub fn reverse_properties_mut(&mut self) -> Option<&mut ReverseProperties<T, B>>
pub fn reverse_properties_mut(&mut self) -> Option<&mut ReverseProperties<T, B>>
Returns a mutable reference to the reverse properties of the node, if
it has a @reverse entry.
Sourcepub fn set_reverse_properties(
&mut self,
reverse_properties: Option<ReverseProperties<T, B>>,
)
pub fn set_reverse_properties( &mut self, reverse_properties: Option<ReverseProperties<T, B>>, )
Sets the reverse properties of this Node.
Sourcepub fn is_unnamed_graph(&self) -> bool
pub fn is_unnamed_graph(&self) -> bool
Tests if the node is an unnamed graph object.
Returns true if the only field of the object is a @graph field,
false otherwise.
Sourcepub fn into_unnamed_graph(self: Box<Self>) -> Result<Graph<T, B>, Box<Self>>
pub fn into_unnamed_graph(self: Box<Self>) -> Result<Graph<T, B>, Box<Self>>
Returns the node as an unnamed graph, if it is one.
The unnamed graph is returned as a set of indexed objects. Fails and returns itself if the node is not an unnamed graph.
§Errors
Returns self unchanged when the object is not a graph object, or is a named graph.
Sourcepub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
pub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
Returns an iterator that visits every fragment of the node: the node itself and, recursively, everything it contains.
Sourcepub fn count(&self, f: impl FnMut(&FragmentRef<'_, T, B>) -> bool) -> usize
pub fn count(&self, f: impl FnMut(&FragmentRef<'_, T, B>) -> bool) -> usize
Counts the fragments of the node matching the given predicate.
Source§impl<T: Eq + Hash, B: Eq + Hash> Node<T, B>
impl<T: Eq + Hash, B: Eq + Hash> Node<T, B>
Sourcepub fn has_key(&self, key: &Term<T, B>) -> bool
pub fn has_key(&self, key: &Term<T, B>) -> bool
Checks if the node object has the given term as key.
§Example
// Checks if the JSON object representation of the node has an `@id` key.
if node.has_key(&Term::Keyword(Keyword::Id)) {
// ...
}Sourcepub fn get<'a, Q: ?Sized + Hash + Equivalent<Id<T, B>>>(
&self,
prop: &Q,
) -> Objects<'_, T, B> ⓘwhere
T: 'a,
pub fn get<'a, Q: ?Sized + Hash + Equivalent<Id<T, B>>>(
&self,
prop: &Q,
) -> Objects<'_, T, B> ⓘwhere
T: 'a,
Returns all the objects associated with the node through the given property.
Sourcepub fn get_any<'a, Q: ?Sized + Hash + Equivalent<Id<T, B>>>(
&self,
prop: &Q,
) -> Option<&IndexedObject<T, B>>where
T: 'a,
pub fn get_any<'a, Q: ?Sized + Hash + Equivalent<Id<T, B>>>(
&self,
prop: &Q,
) -> Option<&IndexedObject<T, B>>where
T: 'a,
Returns one of the objects associated with the node through the given property.
If multiple objects are attached to the node with this property, there is no guarantee on which object is returned.
Sourcepub fn insert(&mut self, prop: Id<T, B>, value: IndexedObject<T, B>)
pub fn insert(&mut self, prop: Id<T, B>, value: IndexedObject<T, B>)
Associates the given object with the node through the given property.
Sourcepub fn insert_all<Objects: Iterator<Item = IndexedObject<T, B>>>(
&mut self,
prop: Id<T, B>,
values: Objects,
)
pub fn insert_all<Objects: Iterator<Item = IndexedObject<T, B>>>( &mut self, prop: Id<T, B>, values: Objects, )
Associates all the given objects with the node through the given property.
If objects are already associated with the property, the new ones are appended to them. Duplicate objects are not removed.
Sourcepub fn reverse_properties_or_insert(
&mut self,
props: ReverseProperties<T, B>,
) -> &mut ReverseProperties<T, B>
pub fn reverse_properties_or_insert( &mut self, props: ReverseProperties<T, B>, ) -> &mut ReverseProperties<T, B>
Mutably borrows the reverse properties, inserting props if there are
none.
Sourcepub fn reverse_properties_or_default(&mut self) -> &mut ReverseProperties<T, B>
pub fn reverse_properties_or_default(&mut self) -> &mut ReverseProperties<T, B>
Mutably borrows the reverse properties, inserting an empty set if there are none.
Sourcepub fn reverse_properties_or_insert_with(
&mut self,
f: impl FnOnce() -> ReverseProperties<T, B>,
) -> &mut ReverseProperties<T, B>
pub fn reverse_properties_or_insert_with( &mut self, f: impl FnOnce() -> ReverseProperties<T, B>, ) -> &mut ReverseProperties<T, B>
Mutably borrows the reverse properties, inserting the result of f if
there are none.
Sourcepub fn equivalent(&self, other: &Self) -> bool
pub fn equivalent(&self, other: &Self) -> bool
Equivalence operator.
Equivalence differs from equality for anonymous objects: an anonymous node object stands for an implicit, unlabeled blank node, so it is never equivalent to anything.
Trait Implementations§
Source§impl<T, B> Any<T, B> for Node<T, B>
impl<T, B> Any<T, B> for Node<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 Node<T, B>
Source§impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContext<N> for Node<T, B>
impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContext<N> for Node<T, B>
Source§impl<T, B, I: Interpretation> LinkedData<I> for Node<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedData<I> for Node<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
Source§impl<T, B, I: Interpretation> LinkedDataGraph<I> for Node<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataGraph<I> for Node<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 Node<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataPredicateObjects<I> for Node<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 Node<T, B>where
T: LinkedDataResource<I>,
B: LinkedDataResource<I>,
impl<T, B, I: Interpretation> LinkedDataResource<I> for Node<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 Node<T, B>where
T: LinkedDataResource<I> + LinkedDataSubject<I>,
B: LinkedDataResource<I> + LinkedDataSubject<I>,
impl<T, B, I: Interpretation> LinkedDataSubject<I> for Node<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, N: Vocabulary<Iri = T, BlankId = B>> PrecomputeSizeWithContext<N> for Node<T, B>
impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrecomputeSizeWithContext<N> for Node<T, B>
Source§impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithContext<N> for Node<T, B>
impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithContext<N> for Node<T, B>
Source§impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithSizeAndContext<N> for Node<T, B>
impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithSizeAndContext<N> for Node<T, B>
Source§impl<T, B> Relabel<T, B> for Node<T, B>
impl<T, B> Relabel<T, B> for Node<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> TryFromJsonObject<T, B> for Node<T, B>
impl<T: Eq + Hash, B: Eq + Hash> TryFromJsonObject<T, B> for Node<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 Node<T, B>
impl<T, B> RefUnwindSafe for Node<T, B>where
Option<Id<T, B>>: RefUnwindSafe,
Option<Vec<Id<T, B>>>: RefUnwindSafe,
Option<Vec<Indexed<Object<T, B>>>>: RefUnwindSafe,
Option<Vec<Indexed<Node<T, B>>>>: RefUnwindSafe,
Properties<T, B>: RefUnwindSafe,
Option<ReverseProperties<T, B>>: RefUnwindSafe,
impl<T, B> Send for Node<T, B>
impl<T, B> Sync for Node<T, B>
impl<T, B> Unpin for Node<T, B>
impl<T, B> UnsafeUnpin for Node<T, B>where
Option<Id<T, B>>: UnsafeUnpin,
Option<Vec<Id<T, B>>>: UnsafeUnpin,
Option<Vec<Indexed<Object<T, B>>>>: UnsafeUnpin,
Option<Vec<Indexed<Node<T, B>>>>: UnsafeUnpin,
Properties<T, B>: UnsafeUnpin,
Option<ReverseProperties<T, B>>: UnsafeUnpin,
impl<T, B> UnwindSafe for Node<T, B>where
Option<Id<T, B>>: UnwindSafe,
Option<Vec<Id<T, B>>>: UnwindSafe,
Option<Vec<Indexed<Object<T, B>>>>: UnwindSafe,
Option<Vec<Indexed<Node<T, B>>>>: UnwindSafe,
Properties<T, B>: UnwindSafe,
Option<ReverseProperties<T, B>>: UnwindSafe,
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.