summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml21
-rw-r--r--examples/src/bin/example_action_system.rs18
-rw-r--r--examples/src/lib.rs1
3 files changed, 40 insertions, 0 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
new file mode 100644
index 0000000..3a6cee2
--- /dev/null
+++ b/examples/Cargo.toml
@@ -0,0 +1,21 @@
+[package]
+name = "examples"
+edition = "2024"
+version.workspace = true
+
+[[bin]]
+name = "example_action_system"
+path = "src/bin/example_action_system.rs"
+
+[dependencies]
+
+# Utils
+tcp_connection = { path = "../crates/utils/tcp_connection" }
+cfg_file = { path = "../crates/utils/cfg_file", features = ["default"] }
+string_proc = { path = "../crates/utils/string_proc" }
+
+# Core
+action_system = { path = "../crates/system_action" }
+
+# Async & Networking
+tokio = { version = "1.46.1", features = ["full"] }
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 @@
+