aboutsummaryrefslogtreecommitdiff
path: root/examples/factory/bootstrap.rs
blob: 5086b1af9a7ed1465ba2a60d20d73e939a236a7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}