dagrs 0.8.1

Dagrs follows the concept of Flow-based Programming and is suitable for the execution of multiple tasks with graph-like dependencies. Dagrs has the characteristics of high performance and asynchronous execution. It provides users with a convenient programming interface.
Documentation
//! # Example: hello_dagrs
//! Creates a `DefaultNode` that returns with "Hello Dagrs",
//! then create a new `Graph` with this node and run.

use std::sync::Arc;

use async_trait::async_trait;
use dagrs::{
    Action, Content, DefaultNode, EnvVar, Graph, InChannels, Node, NodeTable, OutChannels, Output,
};

/// An implementation of [`Action`] that returns [`Output::Out`] containing a String "Hello world".
#[derive(Default)]
pub struct HelloAction;
#[async_trait]
impl Action for HelloAction {
    async fn run(&self, _: &mut InChannels, _: &mut OutChannels, _: Arc<EnvVar>) -> Output {
        Output::Out(Some(Content::new("Hello Dagrs".to_string())))
    }
}

#[tokio::main]
async fn main() {
    // create an empty `NodeTable`
    let mut node_table = NodeTable::new();
    // create a `DefaultNode` with action `HelloAction`
    let hello_node =
        DefaultNode::with_action("Hello Dagrs".to_string(), HelloAction, &mut node_table);
    let id: &dagrs::NodeId = &hello_node.id();

    // create a graph with this node and run
    let mut graph = Graph::new();
    graph.add_node(hello_node).unwrap();
    match graph.async_start().await {
        Ok(_) => {
            // verify the output of this node
            let outputs = graph.get_outputs();
            assert_eq!(outputs.len(), 1);

            let content = outputs.get(id).unwrap().get_out().unwrap();
            let node_output = content.get::<String>().unwrap();
            assert_eq!(node_output, "Hello Dagrs")
        }
        Err(e) => {
            eprintln!("Graph execution failed: {:?}", e);
        }
    }
}