diff --git a/src/rust/engine/src/nodes.rs b/src/rust/engine/src/nodes.rs index 4a00c313838..70ab67a119d 100644 --- a/src/rust/engine/src/nodes.rs +++ b/src/rust/engine/src/nodes.rs @@ -106,8 +106,8 @@ impl StoreFileByDigest for Context { } /// -/// A simplified implementation of graph::Node for members of the NodeKey enum to implement. -/// NodeKey's impl of graph::Node handles the rest. +/// Defines the mapping between a NodeKey and its NodeOutput, to allow for type-safe lookups of +/// (wrapped) `graph` Nodes via `Context::get`. /// /// The Item type of a WrappedNode is bounded to values that can be stored and retrieved /// from the NodeOutput enum. Due to the semantics of memoization, retrieving the typed result @@ -115,20 +115,20 @@ impl StoreFileByDigest for Context { /// combination of bounds at usage sites should mean that a failure to unwrap the result is /// exceedingly rare. /// -#[async_trait] pub trait WrappedNode: Into { type Item: TryFrom; - - async fn run_wrapped_node( - self, - context: Context, - _workunit: &mut RunningWorkunit, - ) -> NodeResult; } /// /// A Node that selects a product for some Params. /// +/// NB: This is a Node so that it can be used as a root in the graph, but it does not implement +/// WrappedNode, because it should never be requested as a Node using context.get. Select is a thin +/// proxy to other Node types (which it requests using context.get), and memoizing it would be +/// redundant. +/// +/// Instead, use `Select::run_node` to run the Select logic without memoizing it. +/// #[derive(Clone, Debug, DeepSizeOf, Eq, Hash, PartialEq)] pub struct Select { pub params: Params, @@ -187,13 +187,13 @@ impl Select { async move { let edges = edges?; Select::new_from_edges(params, product, &edges) - .run(context) + .run_node(context) .await } .boxed() } - async fn run(self, context: Context) -> NodeResult { + async fn run_node(self, context: Context) -> NodeResult { match self.entry.as_ref() { &rule_graph::Entry::WithDeps(wd) => match wd.as_ref() { rule_graph::EntryWithDeps::Inner(ref inner) => match inner.rule() { @@ -241,26 +241,6 @@ impl Select { } } -/// -/// NB: This is a Node so that it can be used as a root in the graph, but it should otherwise -/// never be requested as a Node using context.get. Select is a thin proxy to other Node types -/// (which it requests using context.get), and memoizing it would be redundant. -/// -/// Instead, use `Select::run` to run the Select logic without memoizing it. -/// -#[async_trait] -impl WrappedNode for Select { - type Item = Value; - - async fn run_wrapped_node( - self, - context: Context, - _workunit: &mut RunningWorkunit, - ) -> NodeResult { - self.run(context).await - } -} - impl From