aboutsummaryrefslogtreecommitdiff
path: root/examples/async
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-09-17 18:37:30 +0200
committerHampusM <hampus@hampusmat.com>2022-09-17 18:37:30 +0200
commite210a95b9724bf9c471090d629c5962e3e411711 (patch)
tree3a064e34ad1dd61bcd25fbd5fda72ddacd847f53 /examples/async
parent7de7f73963a266cceff85d6ab71c3256e5d382ec (diff)
docs: add missing modules in the async example
Diffstat (limited to 'examples/async')
-rw-r--r--examples/async/food.rs19
-rw-r--r--examples/async/interfaces/food.rs10
2 files changed, 29 insertions, 0 deletions
diff --git a/examples/async/food.rs b/examples/async/food.rs
new file mode 100644
index 0000000..c2264cf
--- /dev/null
+++ b/examples/async/food.rs
@@ -0,0 +1,19 @@
+use crate::interfaces::food::IFood;
+
+pub struct Food {}
+
+impl Food
+{
+ pub fn new() -> Self
+ {
+ Self {}
+ }
+}
+
+impl IFood for Food
+{
+ fn eat(&self)
+ {
+ println!("Ate food");
+ }
+}
diff --git a/examples/async/interfaces/food.rs b/examples/async/interfaces/food.rs
new file mode 100644
index 0000000..b310a3d
--- /dev/null
+++ b/examples/async/interfaces/food.rs
@@ -0,0 +1,10 @@
+use syrette::factory;
+use syrette::ptr::TransientPtr;
+
+pub trait IFood
+{
+ fn eat(&self);
+}
+
+#[factory(threadsafe = true)]
+pub type IFoodFactory = dyn Fn() -> TransientPtr<dyn IFood>;