pub struct Node {
pub index: String,
pub author: String,
pub time_sent: u64,
pub signatures: Vec<Signature>,
pub contents: NodeContents,
pub hash: Option<String>,
pub children: Vec<Node>,
}
Expand description
Struct which represents a node in a graph in Graph Store
Fields§
§index: String
§time_sent: u64
§signatures: Vec<Signature>
§contents: NodeContents
§hash: Option<String>
§children: Vec<Node>
Implementations§
Source§impl Node
impl Node
pub fn new( index: String, author: String, time_sent: u64, signatures: Vec<Signature>, contents: NodeContents, hash: Option<String>, ) -> Node
Sourcepub fn index_tail(&self) -> String
pub fn index_tail(&self) -> String
Extract the node’s final section (after the last /
) of the index
Sourcepub fn parent_index(&self) -> Option<String>
pub fn parent_index(&self) -> Option<String>
Extract the Node
’s parent’s index (if parent exists)
Sourcepub fn is_parent(&self, potential_child: &Node) -> bool
pub fn is_parent(&self, potential_child: &Node) -> bool
Check if a self is the direct parent of another Node
.
Sourcepub fn is_ancestor(&self, potential_child: &Node) -> bool
pub fn is_ancestor(&self, potential_child: &Node) -> bool
Check if self is a parent (direct or indirect) of another Node
Sourcepub fn add_child(&self, new_child: &Node) -> Node
pub fn add_child(&self, new_child: &Node) -> Node
Creates a copy of self and searches through the children to find
the deepest depth which the new_child
can be placed.
Sourcepub fn time_sent_formatted(&self) -> String
pub fn time_sent_formatted(&self) -> String
Formats the time_sent
field to be human readable date-time in UTC
Sourcepub fn to_json(&self) -> JsonValue
pub fn to_json(&self) -> JsonValue
Converts to JsonValue
creates a json object with one field: key = the node’s full index path, value = json representation of node
Sourcepub fn from_graph_update_json(wrapped_json: &JsonValue) -> Result<Node>
pub fn from_graph_update_json(wrapped_json: &JsonValue) -> Result<Node>
Convert from node JsonValue
which is wrapped up in a few wrapper fields
into a Node
, with children if they exist.
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 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