pub trait Weave<K, N, T>{
type Nodes;
type Roots;
Show 18 methods
// Required methods
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn nodes(&self) -> &Self::Nodes;
fn roots(&self) -> &Self::Roots;
fn contains(&self, id: &K) -> bool;
fn contains_active(&self, id: &K) -> bool;
fn get_node(&self, id: &K) -> Option<&N>;
fn get_node_parents(&self, id: &K) -> Option<&N::From>;
fn get_node_children(&self, id: &K) -> Option<&N::To>;
fn get_ordered_node_identifiers(&mut self, output: &mut Vec<K>);
fn get_ordered_node_identifiers_from(&mut self, id: &K, output: &mut Vec<K>);
fn get_active_path(&mut self, output: &mut Vec<K>);
fn get_path_from(&mut self, id: &K, output: &mut Vec<K>);
fn add_node(&mut self, node: N) -> bool;
fn set_node_active_status(&mut self, id: &K, value: bool) -> bool;
fn remove_node(&mut self, id: &K) -> Option<N>;
fn remove_node_tracked(&mut self, id: &K, on_removal: impl FnMut(N)) -> bool;
fn remove_all_nodes(&mut self);
}Expand description
A document linking together multiple Node objects without cyclical links.
§Deserialization
If a Weave implementation supports deserialization, it must validate internal consistency during the deserialization process in a way which is robust to untrusted inputs.
§Panics
All panics should be assumed to leave the Weave in a malformed state unless otherwise specified by the implementation.
Required Associated Types§
Required Methods§
Sourcefn roots(&self) -> &Self::Roots
fn roots(&self) -> &Self::Roots
Returns a reference to the identifiers of root nodes (nodes which do not have any parents).
Sourcefn contains(&self, id: &K) -> bool
fn contains(&self, id: &K) -> bool
Returns true if the Weave contains a node with the specified identifier.
Sourcefn contains_active(&self, id: &K) -> bool
fn contains_active(&self, id: &K) -> bool
Returns true if the Weave contains an active node (node.is_active() == true) with the specified identifier.
The meaning of this value can depend on the underlying Weave implementation.
Sourcefn get_node(&self, id: &K) -> Option<&N>
fn get_node(&self, id: &K) -> Option<&N>
Returns a reference to the node corresponding to the identifier.
Sourcefn get_node_parents(&self, id: &K) -> Option<&N::From>
fn get_node_parents(&self, id: &K) -> Option<&N::From>
Convenience method for self.get_node(id).map(Node::from).
Sourcefn get_node_children(&self, id: &K) -> Option<&N::To>
fn get_node_children(&self, id: &K) -> Option<&N::To>
Convenience method for self.get_node(id).map(Node::to).
Sourcefn get_ordered_node_identifiers(&mut self, output: &mut Vec<K>)
fn get_ordered_node_identifiers(&mut self, output: &mut Vec<K>)
Builds a list of all node identifiers ordered by their positions in the Weave.
Sourcefn get_ordered_node_identifiers_from(&mut self, id: &K, output: &mut Vec<K>)
fn get_ordered_node_identifiers_from(&mut self, id: &K, output: &mut Vec<K>)
Recursively builds a list of all children of the specified node ordered by their positions in the Weave.
Sourcefn get_active_path(&mut self, output: &mut Vec<K>)
fn get_active_path(&mut self, output: &mut Vec<K>)
Builds a path through the Weave starting at the deepest active node and ending at a root node.
In an ActivePathWeave, this path will be the longest contiguous path of active nodes.
Sourcefn get_path_from(&mut self, id: &K, output: &mut Vec<K>)
fn get_path_from(&mut self, id: &K, output: &mut Vec<K>)
Builds a path through the Weave starting at the specified node and ending at a root node.
In an ActivePathWeave, this path will preferentially route through the active path.
Sourcefn add_node(&mut self, node: N) -> bool
fn add_node(&mut self, node: N) -> bool
Inserts a node into the Weave, returning true if the insertion was successful.
This function may change the active status of nodes if it is necessary to preserve internal consistency.
Sourcefn set_node_active_status(&mut self, id: &K, value: bool) -> bool
fn set_node_active_status(&mut self, id: &K, value: bool) -> bool
Sets the active status of a node with the specified identifier.
This function may change the active status of other nodes in an implementation-specific manner if it is necessary to preserve internal consistency.
Sourcefn remove_node(&mut self, id: &K) -> Option<N>
fn remove_node(&mut self, id: &K) -> Option<N>
Removes a node with the specified identifier, returning its value if it was present within the Weave.
This function may remove or update other nodes if it is necessary to preserve internal consistency.
This function uses the same removal logic as Weave::remove_node_tracked.
Sourcefn remove_node_tracked(&mut self, id: &K, on_removal: impl FnMut(N)) -> bool
fn remove_node_tracked(&mut self, id: &K, on_removal: impl FnMut(N)) -> bool
Removes a node with the specified identifier, returning true if it was present within the Weave.
This function may remove or update other nodes if it is necessary to preserve internal consistency. Every removed node will be returned by the on_removal call, with removal ordering being defined by the Weave implementation.
§Panics
May panic if on_removal panics.
Sourcefn remove_all_nodes(&mut self)
fn remove_all_nodes(&mut self)
Removes all nodes from the Weave.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".