[−][src]Struct json_ld::object::node::Node
A node object.
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).
Methods
impl<T: Id> Node<T>
[src]
pub fn new() -> Node<T>
[src]
Create a new empty node.
pub fn has_key(&self, key: &Term<T>) -> bool
[src]
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)) { ... }
pub fn id(&self) -> Option<&Lenient<Reference<T>>>
[src]
Get the identifier of the node.
This correspond to the @id
field of the JSON object.
pub fn as_iri(&self) -> Option<Iri>
[src]
Get the node's as an IRI if possible.
Returns the node's IRI id if any. Returns None
otherwise.
pub fn as_str(&self) -> Option<&str>
[src]
Get the node's id, is any, as a string slice.
Returns None
if the node has no @id
field.
pub fn types(&self) -> &[Lenient<Reference<T>>]
[src]
Get the list of the node's types.
This returns a list of Lenient
types, including malformed types that are not
IRIs of blank node identifiers.
pub fn has_type<U>(&self, ty: &U) -> bool where
Lenient<Reference<T>>: PartialEq<U>,
[src]
Lenient<Reference<T>>: PartialEq<U>,
Checks if the node has the given type.
pub fn is_empty(&self) -> bool
[src]
Tests if the node is empty.
It is empty is every field except for @id
is empty.
pub fn is_graph(&self) -> bool
[src]
Tests if the node is a graph object (has a @graph
field).
pub fn graph(&self) -> Option<&HashSet<Indexed<Object<T>>>>
[src]
If the node is a graph object, get the graph.
pub fn graph_mut(&mut self) -> Option<&mut HashSet<Indexed<Object<T>>>>
[src]
If the node is a graph object, get the mutable graph.
pub fn set_graph(&mut self, graph: Option<HashSet<Indexed<Object<T>>>>)
[src]
Set the graph.
pub fn included(&self) -> Option<&HashSet<Indexed<Node<T>>>>
[src]
Get the set of nodes included by this node.
This correspond to the @included
field in the JSON representation.
pub fn included_mut(&mut self) -> Option<&mut HashSet<Indexed<Node<T>>>>
[src]
Get the mutable set of nodes included by this node.
This correspond to the @included
field in the JSON representation.
pub fn set_included(&mut self, included: Option<HashSet<Indexed<Node<T>>>>)
[src]
Set the set of nodes included by the node.
pub fn get<'a, Q: ToReference<T>>(&self, prop: Q) -> Objects<T> where
T: 'a,
[src]
T: 'a,
Get all the objects associated to the node with the given property.
pub fn get_any<'a, Q: ToReference<T>>(
&self,
prop: Q
) -> Option<&Indexed<Object<T>>> where
T: 'a,
[src]
&self,
prop: Q
) -> Option<&Indexed<Object<T>>> where
T: 'a,
Get one of the objects associated to the node with the given property.
If multiple objects are attaced to the node with this property, there are no guaranties on which object will be returned.
pub fn insert(&mut self, prop: Reference<T>, value: Indexed<Object<T>>)
[src]
Associate the given object to the node through the given property.
pub fn insert_all<Objects: Iterator<Item = Indexed<Object<T>>>>(
&mut self,
prop: Reference<T>,
values: Objects
)
[src]
&mut self,
prop: Reference<T>,
values: Objects
)
Associate all the given objects to the node through the given property.
pub fn insert_reverse(
&mut self,
reverse_prop: Reference<T>,
reverse_value: Indexed<Node<T>>
)
[src]
&mut self,
reverse_prop: Reference<T>,
reverse_value: Indexed<Node<T>>
)
pub fn insert_all_reverse<Nodes: Iterator<Item = Indexed<Node<T>>>>(
&mut self,
reverse_prop: Reference<T>,
reverse_values: Nodes
)
[src]
&mut self,
reverse_prop: Reference<T>,
reverse_values: Nodes
)
pub fn is_unnamed_graph(&self) -> bool
[src]
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.
pub fn into_unnamed_graph(self) -> Result<HashSet<Indexed<Object<T>>>, Node<T>>
[src]
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.
Trait Implementations
impl<T: Id> AsJson for Node<T>
[src]
impl<T: Eq + Id> Eq for Node<T>
[src]
impl<T: Id> From<Node<T>> for Object<T>
[src]
impl<T: Id> Hash for Node<T>
[src]
fn hash<H: Hasher>(&self, h: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: PartialEq + Id> PartialEq<Node<T>> for Node<T>
[src]
impl<T: Id> StructuralEq for Node<T>
[src]
impl<T: Id> StructuralPartialEq for Node<T>
[src]
impl<T: Id> TryFrom<Object<T>> for Node<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Node<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Node<T> where
T: Send,
T: Send,
impl<T> Sync for Node<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Node<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Node<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T
[src]
type Owned = T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,