pub trait Node<S: GraphState>: Send + Sync {
// Required method
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 S,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn name(&self) -> Option<&str> { ... }
fn retry_policy(&self) -> RetryPolicy { ... }
}Expand description
Trait for graph nodes.
Nodes are async functions that receive the current state and configuration, and return a state update or command.
§Type Parameters
S: The state type for this graph.
§Examples
ⓘ
use regula_core::{Node, NodeOutput, GraphState, RunnableConfig, Result};
use async_trait::async_trait;
struct MyNode;
#[async_trait]
impl<S: GraphState> Node<S> for MyNode {
async fn execute(&self, state: &S, config: &RunnableConfig) -> Result<NodeOutput> {
// Process state and return update
Ok(NodeOutput::update(serde_json::json!({
"counter": 42
})))
}
}Required Methods§
Sourcefn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 S,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 S,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Provided Methods§
Sourcefn retry_policy(&self) -> RetryPolicy
fn retry_policy(&self) -> RetryPolicy
Check if this node should be retried on failure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".