pub trait Node: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn validate_against(&self, _parent: &StateSchema) -> Result<(), GraphError> { ... }
fn validate(&self) -> Result<(), GraphError> { ... }
fn execute_stream<'a>(
&'a self,
ctx: &'a NodeContext,
) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, GraphError>> + Send + 'a>> { ... }
}graph only.Expand description
A node in the graph
Required Methods§
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput, GraphError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput, GraphError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Execute the node and return state updates
Provided Methods§
Sourcefn validate_against(&self, _parent: &StateSchema) -> Result<(), GraphError>
fn validate_against(&self, _parent: &StateSchema) -> Result<(), GraphError>
Rejects a node that cannot execute, before the graph runs.
Called for every node by StateGraph::compile, so a configuration whose
backend is unavailable fails while the graph is being built rather than
part-way through a run, when earlier nodes may already have had side effects.
§Errors
Returns an error describing what is unavailable. The default accepts the node. Checks this node against the schema of the graph that holds it.
Called by StateGraph::compile for
every node, so a node that has requirements on its parent states them
before anything runs. Defaults to accepting any parent.
SubgraphNode uses this to reject a
channel mapping that names a channel neither side declares.
fn validate(&self) -> Result<(), GraphError>
Sourcefn execute_stream<'a>(
&'a self,
ctx: &'a NodeContext,
) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, GraphError>> + Send + 'a>>
fn execute_stream<'a>( &'a self, ctx: &'a NodeContext, ) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, GraphError>> + Send + 'a>>
Streams execution events for this node.
An implementation must report the node’s state updates by yielding a
StreamEvent::Updates event, because a streaming executor takes the
updates from this stream rather than executing the node a second time.
The default implementation wraps Node::execute and does so.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".