aboutsummaryrefslogtreecommitdiff
path: root/examples/factory/bootstrap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/factory/bootstrap.rs')
-rw-r--r--examples/factory/bootstrap.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/factory/bootstrap.rs b/examples/factory/bootstrap.rs
new file mode 100644
index 0000000..5086b1a
--- /dev/null
+++ b/examples/factory/bootstrap.rs
@@ -0,0 +1,24 @@
+use syrette::ptr::InterfacePtr;
+use syrette::DIContainer;
+
+// Interfaces
+use crate::interfaces::user::{IUser, IUserFactory};
+//
+// Concrete implementations
+use crate::user::User;
+
+pub fn bootstrap() -> DIContainer
+{
+ let mut di_container: DIContainer = DIContainer::new();
+
+ di_container
+ .bind::<IUserFactory>()
+ .to_factory(&|name, date_of_birth, password| {
+ let user: InterfacePtr<dyn IUser> =
+ InterfacePtr::new(User::new(name, date_of_birth, password));
+
+ user
+ });
+
+ di_container
+}