summaryrefslogtreecommitdiff
path: root/examples/src/bin/example_action_system.rs
blob: 776c98260459f6b755a75d0a21eb8a6d40a7c40b (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_pool::ActionPool, macros::action_gen};
use tcp_connection::error::TcpTargetError;

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

    proc_print_name_action(&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(())
}