Skip to main content

Node

Trait Node 

Source
pub trait Node:
    Debug
    + Send
    + Sync {
    // Required methods
    fn kind(&self) -> WorkflowNodeType;
    fn id(&self) -> &str;
    fn position(&self) -> usize;
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), NodeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Parameter>, NodeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn create_msg<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Message> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

The Node trait is to be implemented by all node types that can occur in a workflow

The Node trait is designed to be used as a trait object which allow us to erase (type erasure) the concrete type and instead rely on the methods solely available through this trait.

Required Methods§

Source

fn kind(&self) -> WorkflowNodeType

Return the type of node, this is used for easily locating the Start and End nodes

Source

fn id(&self) -> &str

The current node ID, used by the Job struct to know the current node

Source

fn position(&self) -> usize

A pointer to the current nodes position in the Job.nodes collection

Source

fn run<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), NodeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The publicly exposed API for running a node

Provided Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Parameter>, NodeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The instructions for how to execute each node

Source

fn create_msg<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Message> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create message to be sent to the executor once the node has been executed

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§