Skip to main content

Weave

Trait Weave 

Source
pub trait Weave<K, N, T>
where K: Hash + Copy + Eq + Ord, N: Node<K, 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§

Source

type Nodes

Mapping between identifiers and nodes.

Source

type Roots

Identifiers of root nodes (nodes which do not have any parents).

Required Methods§

Source

fn len(&self) -> usize

Returns the number of nodes stored within the Weave.

Source

fn is_empty(&self) -> bool

Returns true if the Weave does not contain any nodes.

Source

fn nodes(&self) -> &Self::Nodes

Returns a reference to the identifier:node mapping.

Source

fn roots(&self) -> &Self::Roots

Returns a reference to the identifiers of root nodes (nodes which do not have any parents).

Source

fn contains(&self, id: &K) -> bool

Returns true if the Weave contains a node with the specified identifier.

Source

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.

Source

fn get_node(&self, id: &K) -> Option<&N>

Returns a reference to the node corresponding to the identifier.

Source

fn get_node_parents(&self, id: &K) -> Option<&N::From>

Convenience method for self.get_node(id).map(Node::from).

Source

fn get_node_children(&self, id: &K) -> Option<&N::To>

Convenience method for self.get_node(id).map(Node::to).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§

Source§

impl<K, T, M, S> Weave<K, DependentNode<K, T, S>, T> for DependentWeave<K, T, M, S>
where K: Hash + Copy + Eq + Ord, S: BuildHasher + Default + Clone,

Source§

type Nodes = HashMap<K, DependentNode<K, T, S>, S>

Source§

type Roots = IndexSet<K, S>

Source§

impl<K, T, M, S> Weave<K, IndependentNode<K, T, S>, T> for IndependentWeave<K, T, M, S>

Source§

type Nodes = HashMap<K, IndependentNode<K, T, S>, S>

Source§

type Roots = IndexSet<K, S>

Source§

impl<W, K, N, T, M> Weave<K, N, T> for LoggedWeave<W, K, N, T, M>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T> + Clone,

Source§

type Nodes = <W as Weave<K, N, T>>::Nodes

Source§

type Roots = <W as Weave<K, N, T>>::Roots

Source§

impl<W, K, N, T> Weave<K, N, T> for CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

type Nodes = <W as Weave<K, N, T>>::Nodes

Source§

type Roots = <W as Weave<K, N, T>>::Roots