blob: 5f63b472fcf09505dc5b17add816afe9f2032d10 (
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::DIContainer;
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)
}
|