aboutsummaryrefslogtreecommitdiff
path: root/examples/with-3rd-party/bootstrap.rs
blob: 5d2f713abd835c271ce51f44015403eadf45364b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::error::Error;

use syrette::ptr::TransientPtr;
use syrette::DIContainer;
use third_party_lib::Shuriken;

use crate::interfaces::ninja::INinja;
use crate::ninja::Ninja;

pub fn bootstrap() -> Result<DIContainer, Box<dyn Error>>
{
    let mut di_container = DIContainer::new();

    di_container.bind::<dyn INinja>().to::<Ninja>()?;

    di_container
        .bind::<Shuriken>()
        .to_dynamic_value(&|_| Box::new(|| TransientPtr::new(Shuriken::new())))?;

    Ok(di_container)
}