blob: f7edc5dab53d28213490272a2ddc7dde6b5b64a9 (
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
25
26
27
28
29
30
31
|
use std::rc::Rc;
use anyhow::Result;
use syrette::di_container::blocking::prelude::*;
use crate::interfaces::ninja::INinja;
use crate::interfaces::weapon::IWeapon;
use crate::katana::Katana;
use crate::ninja::Ninja;
use crate::shuriken::Shuriken;
pub fn bootstrap() -> Result<Rc<DIContainer>>
{
let mut di_container = DIContainer::new();
di_container
.bind::<dyn IWeapon>()
.to::<Katana>()?
.in_transient_scope()
.when_named("strong")?;
di_container
.bind::<dyn IWeapon>()
.to::<Shuriken>()?
.in_transient_scope()
.when_named("weak")?;
di_container.bind::<dyn INinja>().to::<Ninja>()?;
Ok(di_container)
}
|