turbo_tasks/graph/
graph_store.rs

1/// A graph store is a data structure that will be built up during a graph
2/// traversal. It is used to store the results of the traversal.
3pub trait GraphStore: Send {
4    type Node: Send;
5    type Edge: Send;
6    type Handle: Send;
7
8    // TODO(alexkirsz) An `entry(from_handle) -> Entry` API would be more
9    // efficient, as right now we're getting the same key multiple times.
10    /// Inserts a node into the graph store, and returns a handle to it.
11    ///
12    /// If this method returns `None`, the node edges will not be visited.
13    fn insert(&mut self, from: Option<(&Self::Handle, Self::Edge)>, node: Self::Node);
14
15    /// Tries to enter a node during traversal for visiting its edges.
16    /// Returns `true` if the node edges should be visited.
17    /// Returns `false` if the node has already been visited and should not be explored again.
18    fn try_enter(&mut self, node: &Self::Node) -> Option<Self::Handle>;
19}