pub struct Node<T = IriBuf, B = BlankIdBuf, M = ()> { /* private fields */ }
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 includes nodes
(@included
field).
Implementations§
source§impl<T, B, M> Node<T, B, M>
impl<T, B, M> Node<T, B, M>
sourcepub fn with_id(id: Entry<Id<T, B>, M>) -> Node<T, B, M>
pub fn with_id(id: Entry<Id<T, B>, M>) -> Node<T, B, M>
Creates a new empty node with the given id.
pub fn from_parts(parts: Parts<T, B, M>) -> Node<T, B, M>
pub fn into_parts(self) -> Parts<T, B, M>
sourcepub fn id(&self) -> Option<&Meta<Id<T, B>, M>>
pub fn id(&self) -> Option<&Meta<Id<T, B>, M>>
Get the identifier of the node.
This correspond to the @id
field of the JSON object.
sourcepub fn id_entry(&self) -> Option<&Entry<Id<T, B>, M>>
pub fn id_entry(&self) -> Option<&Entry<Id<T, B>, M>>
Get the identifier of the node.
This correspond to the @id
field of the JSON object.
sourcepub fn identify_all_with<V, G>(&mut self, vocabulary: &mut V, generator: &mut G)where
V: Vocabulary<Iri = T, BlankId = B>,
G: MetaGenerator<V, M>,
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
pub fn identify_all_with<V, G>(&mut self, vocabulary: &mut V, generator: &mut G)where
V: Vocabulary<Iri = T, BlankId = B>,
G: MetaGenerator<V, M>,
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
Assigns an identifier to this node and every other node included in this
one using the given generator
.
sourcepub fn identify_all<G>(&mut self, generator: &mut G)where
G: MetaGenerator<(), M>,
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
(): Vocabulary<Iri = T, BlankId = B>,
pub fn identify_all<G>(&mut self, generator: &mut G)where
G: MetaGenerator<(), M>,
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
(): Vocabulary<Iri = T, BlankId = B>,
Assigns an identifier to this node and every other node included in this one using the given generator
.
sourcepub fn canonicalize_with(&mut self, buffer: &mut Buffer)
pub fn canonicalize_with(&mut self, buffer: &mut Buffer)
Puts this node object literals 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 node object literals into canonical form.
sourcepub fn as_iri(&self) -> Option<&T>
pub fn as_iri(&self) -> Option<&T>
Get the node’s as an IRI if possible.
Returns the node’s IRI id if any. Returns None
otherwise.
sourcepub fn as_str(&self) -> Option<&str>where
T: AsRef<str>,
pub fn as_str(&self) -> Option<&str>where
T: AsRef<str>,
Get the node’s id, is any, as a string slice.
Returns None
if the node has no @id
field.
sourcepub fn types_mut(&mut self) -> &mut [Meta<Id<T, B>, M>]
pub fn types_mut(&mut self) -> &mut [Meta<Id<T, B>, M>]
Returns a mutable reference to the node’s types.
pub fn type_entry_or_default(
&mut self,
key_metadata: M,
value_metadata: M
) -> &mut Entry<Vec<Meta<Id<T, B>, M>, Global>, M>
pub fn type_entry_or_insert(
&mut self,
key_metadata: M,
value: Meta<Vec<Meta<Id<T, B>, M>, Global>, M>
) -> &mut Entry<Vec<Meta<Id<T, B>, M>, Global>, M>
pub fn type_entry_or_insert_with(
&mut self,
f: impl FnOnce() -> Entry<Vec<Meta<Id<T, B>, M>, Global>, M>
) -> &mut Entry<Vec<Meta<Id<T, B>, M>, Global>, M>
pub fn type_entry(&self) -> Option<&Entry<Vec<Meta<Id<T, B>, M>, Global>, M>>
pub fn set_type_entry(
&mut self,
entry: Option<Entry<Vec<Meta<Id<T, B>, M>, Global>, M>>
)
sourcepub fn has_type<U>(&self, ty: &U) -> boolwhere
Id<T, B>: PartialEq<U>,
pub fn has_type<U>(&self, ty: &U) -> boolwhere
Id<T, B>: PartialEq<U>,
Checks if the node has the given type.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Tests if the node is empty.
It is empty is 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).
Note that node objects may have a @graph entry,
but are not considered graph objects if they include any other entries 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<&Meta<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
pub fn graph(
&self
) -> Option<&Meta<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
If the node is a graph object, get the graph.
sourcepub fn graph_mut(
&mut self
) -> Option<&mut Meta<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
pub fn graph_mut(
&mut self
) -> Option<&mut Meta<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
If the node is a graph object, get the mutable graph.
sourcepub fn graph_entry(
&self
) -> Option<&Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
pub fn graph_entry(
&self
) -> Option<&Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
If the node is a graph object, get the graph.
sourcepub fn graph_entry_mut(
&mut self
) -> Option<&mut Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
pub fn graph_entry_mut(
&mut self
) -> Option<&mut Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
If the node is a graph object, get the mutable graph.
sourcepub fn set_graph(
&mut self,
graph: Option<Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
)
pub fn set_graph(
&mut self,
graph: Option<Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>>
)
Set the graph.
sourcepub fn included_entry(
&self
) -> Option<&Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
pub fn included_entry(
&self
) -> Option<&Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
Get the set of nodes included by this node.
This correspond to the @included
field in the JSON representation.
sourcepub fn included_entry_mut(
&mut self
) -> Option<&mut Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
pub fn included_entry_mut(
&mut self
) -> Option<&mut Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
Get the mutable set of nodes included by this node.
This correspond to the @included
field in the JSON representation.
sourcepub fn included(
&self
) -> Option<&Meta<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
pub fn included(
&self
) -> Option<&Meta<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
Returns a reference to the set of @included
nodes.
sourcepub fn included_mut(
&mut self
) -> Option<&mut Meta<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
pub fn included_mut(
&mut self
) -> Option<&mut Meta<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
Returns a mutable reference to the set of @included
nodes.
sourcepub fn set_included(
&mut self,
included: Option<Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
)
pub fn set_included(
&mut self,
included: Option<Entry<HashSet<Stripped<Meta<Indexed<Node<T, B, M>, M>, M>>, RandomState>, M>>
)
Set the set of nodes included by the node.
sourcepub fn properties(&self) -> &Properties<T, B, M>
pub fn properties(&self) -> &Properties<T, B, M>
Returns a reference to the properties of the node.
sourcepub fn properties_mut(&mut self) -> &mut Properties<T, B, M>
pub fn properties_mut(&mut self) -> &mut Properties<T, B, M>
Returns a mutable reference to the properties of the node.
sourcepub fn reverse_properties(&self) -> Option<&Meta<ReverseProperties<T, B, M>, M>>
pub fn reverse_properties(&self) -> Option<&Meta<ReverseProperties<T, B, M>, M>>
Returns a reference to the properties of the node.
sourcepub fn reverse_properties_entry(
&self
) -> Option<&Entry<ReverseProperties<T, B, M>, M>>
pub fn reverse_properties_entry(
&self
) -> Option<&Entry<ReverseProperties<T, B, M>, M>>
Returns a reference to the reverse properties of the node.
sourcepub fn reverse_properties_mut(
&mut self
) -> Option<&mut Entry<ReverseProperties<T, B, M>, M>>
pub fn reverse_properties_mut(
&mut self
) -> Option<&mut Entry<ReverseProperties<T, B, M>, M>>
Returns a mutable reference to the reverse properties of the node.
pub fn set_reverse_properties(
&mut self,
reverse_properties: Option<Entry<ReverseProperties<T, B, M>, M>>
)
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
is the only field of the object is a @graph
field.
Returns false
otherwise.
sourcepub fn into_unnamed_graph(
self
) -> Result<Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>, Node<T, B, M>>
pub fn into_unnamed_graph(
self
) -> Result<Entry<HashSet<Stripped<Meta<Indexed<Object<T, B, M>, M>, M>>, RandomState>, M>, Node<T, B, M>>
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.
pub fn traverse(&self) -> Traverse<'_, T, B, M> ⓘ
pub fn entries(&self) -> Entries<'_, T, B, M> ⓘ
source§impl<T, B, M> Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
impl<T, B, M> Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
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>(&self, prop: &Q) -> Objects<'_, T, B, M> ⓘwhere
Q: Hash + Equivalent<Id<T, B>> + ?Sized,
T: 'a,
pub fn get<'a, Q>(&self, prop: &Q) -> Objects<'_, T, B, M> ⓘwhere
Q: Hash + Equivalent<Id<T, B>> + ?Sized,
T: 'a,
Get all the objects associated to the node with the given property.
sourcepub fn get_any<'a, Q>(
&self,
prop: &Q
) -> Option<&Meta<Indexed<Object<T, B, M>, M>, M>>where
Q: Hash + Equivalent<Id<T, B>> + ?Sized,
T: 'a,
pub fn get_any<'a, Q>(
&self,
prop: &Q
) -> Option<&Meta<Indexed<Object<T, B, M>, M>, M>>where
Q: Hash + Equivalent<Id<T, B>> + ?Sized,
T: 'a,
Get one of the objects associated to the node with the given property.
If multiple objects are attached to the node with this property, there are no guaranties on which object will be returned.
sourcepub fn insert(
&mut self,
prop: Meta<Id<T, B>, M>,
value: Meta<Indexed<Object<T, B, M>, M>, M>
)
pub fn insert(
&mut self,
prop: Meta<Id<T, B>, M>,
value: Meta<Indexed<Object<T, B, M>, M>, M>
)
Associates the given object to the node through the given property.
sourcepub fn insert_all<Objects>(&mut self, prop: Meta<Id<T, B>, M>, values: Objects)where
Objects: Iterator<Item = Meta<Indexed<Object<T, B, M>, M>, M>>,
pub fn insert_all<Objects>(&mut self, prop: Meta<Id<T, B>, M>, values: Objects)where
Objects: Iterator<Item = Meta<Indexed<Object<T, B, M>, M>, M>>,
Associates all the given objects to the node through the given property.
If there already exists objects associated to the given reverse property,
reverse_value
is added to the list. Duplicate objects are not removed.
pub fn reverse_properties_or_insert(
&mut self,
key_metadata: M,
props: Meta<ReverseProperties<T, B, M>, M>
) -> &mut Entry<ReverseProperties<T, B, M>, M>
pub fn reverse_properties_or_default(
&mut self,
key_metadata: M,
value_metadata: M
) -> &mut Entry<ReverseProperties<T, B, M>, M>
pub fn reverse_properties_or_insert_with(
&mut self,
f: impl FnOnce() -> Entry<ReverseProperties<T, B, M>, M>
) -> &mut Entry<ReverseProperties<T, B, M>, M>
sourcepub fn equivalent(&self, other: &Node<T, B, M>) -> bool
pub fn equivalent(&self, other: &Node<T, B, M>) -> bool
Equivalence operator.
Equivalence is different from equality for anonymous objects. Anonymous node objects have an implicit unlabeled blank nodes and thus never equivalent.
Trait Implementations§
source§impl<T, B, M> Any<T, B, M> for Node<T, B, M>
impl<T, B, M> Any<T, B, M> for Node<T, B, 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, B, M, N> IntoJsonWithContextMeta<M, N> for Node<T, B, M>where
M: Clone,
N: Vocabulary<Iri = T, BlankId = B>,
impl<T, B, M, N> IntoJsonWithContextMeta<M, N> for Node<T, B, M>where
M: Clone,
N: Vocabulary<Iri = T, BlankId = B>,
source§impl<T, B, M> PartialEq<Node<T, B, M>> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
M: PartialEq<M>,
impl<T, B, M> PartialEq<Node<T, B, M>> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
M: PartialEq<M>,
source§impl<T, B, M, N> PrecomputeSizeWithContext<N> for Node<T, B, M>where
N: Vocabulary<Iri = T, BlankId = B>,
impl<T, B, M, N> PrecomputeSizeWithContext<N> for Node<T, B, M>where
N: Vocabulary<Iri = T, BlankId = B>,
source§impl<T, B, M, N> PrintWithSizeAndContext<N> for Node<T, B, M>where
N: Vocabulary<Iri = T, BlankId = B>,
impl<T, B, M, N> PrintWithSizeAndContext<N> for Node<T, B, M>where
N: Vocabulary<Iri = T, BlankId = B>,
source§impl<T, B, M> Relabel<T, B, M> for Node<T, B, M>
impl<T, B, M> Relabel<T, B, M> for Node<T, B, M>
fn relabel_with<N, G>(
&mut self,
vocabulary: &mut N,
generator: &mut G,
relabeling: &mut HashMap<B, Meta<Subject<T, B>, M>, BuildHasherDefault<AHasher>, Global>
)where
N: Vocabulary<Iri = T, BlankId = B>,
G: MetaGenerator<N, M>,
M: Clone,
T: Clone + Eq + Hash,
B: Clone + Eq + Hash,
source§impl<T, B, M> StrippedHash for Node<T, B, M>where
T: Hash,
B: Hash,
impl<T, B, M> StrippedHash for Node<T, B, M>where
T: Hash,
B: Hash,
fn stripped_hash<H>(&self, h: &mut H)where
H: Hasher,
source§impl<T, B, M> StrippedPartialEq<Node<T, B, M>> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
impl<T, B, M> StrippedPartialEq<Node<T, B, M>> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
fn stripped_eq(&self, other: &Node<T, B, M>) -> bool
source§impl<T, B, M> TryFromJsonObject<T, B, M> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
impl<T, B, M> TryFromJsonObject<T, B, M> for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
fn try_from_json_object_in(
vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>,
object: Meta<Object<M>, M>
) -> Result<Meta<Node<T, B, M>, M>, Meta<InvalidExpandedJson<M>, M>>
impl<T, B, M> Eq for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
M: Eq,
impl<T, B, M> StrippedEq for Node<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
Auto Trait Implementations§
impl<T, B, M> RefUnwindSafe for Node<T, B, M>where
B: RefUnwindSafe,
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, B, M> Send for Node<T, B, M>where
B: Send,
M: Send,
T: Send,
impl<T, B, M> Sync for Node<T, B, M>where
B: Sync,
M: Sync,
T: Sync,
impl<T, B, M> Unpin for Node<T, B, M>where
B: Unpin,
M: Unpin,
T: Unpin,
impl<T, B, M> UnwindSafe for Node<T, B, M>where
B: UnwindSafe,
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.