Struct json_ld::Node

source ·
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§

Creates a new empty node.

Creates a new empty node with the given id.

Get the identifier of the node.

This correspond to the @id field of the JSON object.

source

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.

Sets the idntifier of this node.

Assigns an identifier to this node and every other node included in this one using the given generator.

Assigns an identifier to this node and every other node included in this one using the given generator.

Puts this node object literals into canonical form using the given buffer.

The buffer is used to compute the canonical form of numbers.

Puts this node object literals into canonical form.

Get the node’s as an IRI if possible.

Returns the node’s IRI id if any. Returns None otherwise.

Get the node’s id, is any, as a string slice.

Returns None if the node has no @id field.

Get the list of the node’s types.

Returns a mutable reference to the node’s types.

source

pub fn type_entry_or_default(
    &mut self,
    key_metadata: M,
    value_metadata: M
) -> &mut Entry<Vec<Meta<Id<T, B>, M>, Global>, M>

source

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>

source

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>

source

pub fn type_entry(&self) -> Option<&Entry<Vec<Meta<Id<T, B>, M>, Global>, M>>

source

pub fn set_type_entry(
    &mut self,
    entry: Option<Entry<Vec<Meta<Id<T, B>, M>, Global>, M>>
)

Checks if the node has the given type.

Tests if the node is empty.

It is empty is every field other than @id is empty.

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.

Tests if the node is a simple graph object (a graph object without @id field)

If the node is a graph object, get the graph.

If the node is a graph object, get the mutable graph.

source

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.

source

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.

Set the graph.

source

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.

source

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.

Returns a reference to the set of @included nodes.

Returns a mutable reference to the set of @included nodes.

Set the set of nodes included by the node.

Returns a reference to the properties of the node.

Returns a mutable reference to the properties of the node.

Returns a reference to the properties of the node.

source

pub fn reverse_properties_entry(
    &self
) -> Option<&Entry<ReverseProperties<T, B, M>, M>>

Returns a reference to the reverse properties of the node.

Returns a mutable reference to the reverse properties of the node.

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.

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.

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)) {
  // ...
}

Get all the objects associated to the node with the given property.

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.

Associates the given object to the node through the given property.

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.

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§

fn id_entry<'a>(&'a self) -> Option<&'a Entry<Id<T, B>, M>>where
    M: 'a,

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Structural equality with mapped blank identifiers. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Wraps self inside a Meta<Self, M> using the given metadata. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Checks if this value is equivalent to the given key. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.