summaryrefslogtreecommitdiff
path: root/examples/src/bin/example_action_system.rs
blob: a659eb38c7c3c45aa14251a4d612cfa085b42d87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use action_system::{action::ActionContext, action_gen, action_pool::ActionPool};
use tcp_connection::error::TcpTargetError;

#[tokio::main]
async fn main() {
    let mut pool = ActionPool::new();
    PrintNameAction::register_to_pool(&mut pool);

    PrintNameAction::process_at_pool(&pool, ActionContext::local(), "World".to_string())
        .await
        .unwrap();
}

#[action_gen]
async fn print_name_action(_ctx: ActionContext, name: String) -> Result<(), TcpTargetError> {
    println!("Hello, {}!", name);
    Ok(())
}