summaryrefslogtreecommitdiff
path: root/examples/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-06 17:20:31 +0800
committer魏曹先生 <1992414357@qq.com>2025-10-06 17:20:31 +0800
commit58a2c77dace3091fda4ba3903f700b8e928f90c1 (patch)
tree552ee7cf6125e723ec6da89895aa56bb6e5bedde /examples/src
parentdd9e70ad313a7d505370217a411bca41dbb5d36e (diff)
feat: add examples demonstrating action system usage
- Create examples workspace member - Add example_action_system binary showcasing macro usage - Demonstrate action registration and processing workflow
Diffstat (limited to 'examples/src')
-rw-r--r--examples/src/bin/example_action_system.rs18
-rw-r--r--examples/src/lib.rs1
2 files changed, 19 insertions, 0 deletions
diff --git a/examples/src/bin/example_action_system.rs b/examples/src/bin/example_action_system.rs
new file mode 100644
index 0000000..a659eb3
--- /dev/null
+++ b/examples/src/bin/example_action_system.rs
@@ -0,0 +1,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(())
+}
diff --git a/examples/src/lib.rs b/examples/src/lib.rs
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/examples/src/lib.rs
@@ -0,0 +1 @@
+