Skip to main content

Node

Trait Node 

Source
pub trait Node<S: State>: Send + Sync {
    // Required method
    fn process<'life0, 'async_trait>(
        &'life0 self,
        state: S,
    ) -> Pin<Box<dyn Future<Output = Result<NodeOutput<S>, SynapticError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A node in the graph that processes state.

Nodes return NodeOutput<S> which is either a state update or a Command for dynamic control flow.

For backwards compatibility, returning Ok(state.into()) works via the From<S> for NodeOutput<S> impl.

Required Methods§

Source

fn process<'life0, 'async_trait>( &'life0 self, state: S, ) -> Pin<Box<dyn Future<Output = Result<NodeOutput<S>, SynapticError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§

Source§

impl Node<MessageState> for ToolNode

Source§

impl<S, F, Fut> Node<S> for FnNode<S, F, Fut>
where S: State, F: Fn(S) -> Fut + Send + Sync, Fut: Future<Output = Result<NodeOutput<S>, SynapticError>> + Send,