aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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>;