BoxedNode

Trait BoxedNode 

Source
pub trait BoxedNode<Input, Output, Error, Context> {
    // Required methods
    fn run_boxed<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        input: Input,
        context: &'life1 mut Context,
    ) -> Pin<Box<dyn Future<Output = Result<Output, Error>> + Send + 'async_trait>>
       where Input: 'async_trait,
             Output: 'async_trait,
             Error: 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn describe(&self) -> Description;
}
Available on crate feature boxed_node only.
Expand description

The BoxedNode trait is a dyn compatible wrapper around the Node trait.

BoxedNode trait provides the same functions as the Node trait with the addition of dyn compatibility. This allows you to use Box<dyn BoxedNode<...>>.

Blanket implementation of BoxedNode is implemented for all types that implement Node trait.

See also Node.

§Examples

use node_flow::node::BoxedNode;

async fn run_node(
    node: &mut dyn BoxedNode<String, String, String, ()>,
) {
    let result = node.run_boxed("hello".into(), &mut ()).await;
    println!("{:?}", result);
}

Required Methods§

Source

fn run_boxed<'life0, 'life1, 'async_trait>( &'life0 mut self, input: Input, context: &'life1 mut Context, ) -> Pin<Box<dyn Future<Output = Result<Output, Error>> + Send + 'async_trait>>
where Input: 'async_trait, Output: 'async_trait, Error: 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs the node.

This method is equivalent to Node::run, but allows calling it via a Box<dyn BoxedNode<...>> trait object.

§Returns

Boxed dyn Future (Pin<Box<dyn Future<...> + Send + '_>>) that resolves to a Result<Output, Error>.

See also Node::run.

Source

fn describe(&self) -> Description

Describes this node, its type signature and other specifics.

See Description for more details. See also Node::describe.

Implementors§

Source§

impl<Input, Output, Error, Context, T> BoxedNode<Input, Output, Error, Context> for T
where T: Node<Input, Output, Error, Context>,