aboutsummaryrefslogtreecommitdiff
path: root/examples/async/bootstrap.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-09-17 16:12:45 +0200
committerHampusM <hampus@hampusmat.com>2022-09-17 16:12:45 +0200
commit8651f84f205da7a89f2fc7333d1dd8de0d80a22b (patch)
treea178427abb442e897d21f654db71cc8135236920 /examples/async/bootstrap.rs
parentc1e682c25c24be3174d44ceb95b0537c38299d0c (diff)
refactor!: make async DI container be used inside of a Arc
BREAKING CHANGE: The async DI container is to be used inside of a Arc & it also no longer implements Default
Diffstat (limited to 'examples/async/bootstrap.rs')
-rw-r--r--examples/async/bootstrap.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/async/bootstrap.rs b/examples/async/bootstrap.rs
index b640712..7e1d2cd 100644
--- a/examples/async/bootstrap.rs
+++ b/examples/async/bootstrap.rs
@@ -1,3 +1,5 @@
+use std::sync::Arc;
+
use anyhow::Result;
use syrette::async_di_container::AsyncDIContainer;
@@ -11,18 +13,19 @@ use crate::interfaces::cat::ICat;
use crate::interfaces::dog::IDog;
use crate::interfaces::human::IHuman;
-pub async fn bootstrap() -> Result<AsyncDIContainer>
+pub async fn bootstrap() -> Result<Arc<AsyncDIContainer>>
{
let mut di_container = AsyncDIContainer::new();
di_container
.bind::<dyn IDog>()
- .to::<Dog>()?
+ .to::<Dog>()
+ .await?
.in_singleton_scope()
.await?;
- di_container.bind::<dyn ICat>().to::<Cat>()?;
- di_container.bind::<dyn IHuman>().to::<Human>()?;
+ di_container.bind::<dyn ICat>().to::<Cat>().await?;
+ di_container.bind::<dyn IHuman>().to::<Human>().await?;
Ok(di_container)
}