pub struct Node {
pub id: NodeId,
pub labels: SmallVec<[ArcStr; 2]>,
pub properties: PropertyMap,
}Expand description
A node with its labels and properties fully loaded.
This is what you get back from LpgStore::get_node().
For bulk operations, the store works with NodeRecord internally.
§Example
use grafeo_core::graph::lpg::Node;
use grafeo_common::types::NodeId;
let mut person = Node::new(NodeId::new(1));
person.add_label("Person");
person.set_property("name", "Alix");
person.set_property("age", 30i64);
assert!(person.has_label("Person"));Fields§
§id: NodeIdUnique identifier.
labels: SmallVec<[ArcStr; 2]>Labels attached to this node (inline storage for 1-2 labels).
properties: PropertyMapProperties stored on this node.
Implementations§
Source§impl Node
impl Node
Sourcepub fn with_labels(
id: NodeId,
labels: impl IntoIterator<Item = impl Into<ArcStr>>,
) -> Self
pub fn with_labels( id: NodeId, labels: impl IntoIterator<Item = impl Into<ArcStr>>, ) -> Self
Creates a new node with labels.
Sourcepub fn remove_label(&mut self, label: &str) -> bool
pub fn remove_label(&mut self, label: &str) -> bool
Removes a label from this node.
Sourcepub fn set_property(
&mut self,
key: impl Into<PropertyKey>,
value: impl Into<Value>,
)
pub fn set_property( &mut self, key: impl Into<PropertyKey>, value: impl Into<Value>, )
Sets a property on this node.
Sourcepub fn get_property(&self, key: &str) -> Option<&Value>
pub fn get_property(&self, key: &str) -> Option<&Value>
Gets a property from this node.
Sourcepub fn remove_property(&mut self, key: &str) -> Option<Value>
pub fn remove_property(&mut self, key: &str) -> Option<Value>
Removes a property from this node.
Sourcepub fn properties_as_btree(&self) -> BTreeMap<PropertyKey, Value>
pub fn properties_as_btree(&self) -> BTreeMap<PropertyKey, Value>
Returns the properties as a BTreeMap (for serialization compatibility).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more