Skip to main content

GraphNode

Trait GraphNode 

Source
pub trait GraphNode<S: StateSchema>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        state: &'life1 S,
        config: Option<NodeConfig>,
    ) -> Pin<Box<dyn Future<Output = Result<StateUpdate<S>, GraphError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn name(&self) -> &str;
}
Expand description

Graph Node trait

Nodes are async functions that take a state and return a state update. They represent the work units in the graph.

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 S, config: Option<NodeConfig>, ) -> Pin<Box<dyn Future<Output = Result<StateUpdate<S>, GraphError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the node

§Parameters
  • state: Current state of the graph
  • config: Optional configuration for this execution
§Returns

A state update that will be merged into the current state

Source

fn name(&self) -> &str

Get node name

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: StateSchema + 'static, SubS: StateSchema + 'static> GraphNode<S> for SubgraphNode<S, SubS>

Source§

impl<S: StateSchema, F: AsyncFn<S> + 'static> GraphNode<S> for AsyncNode<S, F>

Source§

impl<S: StateSchema, F> GraphNode<S> for FunctionNode<S, F>
where F: Fn(&S) -> Pin<Box<dyn Future<Output = Result<StateUpdate<S>, GraphError>> + Send>> + Send + Sync + 'static,

Source§

impl<S: StateSchema, F> GraphNode<S> for SyncNode<S, F>
where F: Fn(&S) -> Result<StateUpdate<S>, GraphError> + Send + Sync + 'static,

Source§

impl<S: StateSchema> GraphNode<S> for SentinelNode