diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-29 20:52:56 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-29 21:01:32 +0200 |
commit | 080cc42bb1da09059dbc35049a7ded0649961e0c (patch) | |
tree | 307ee564124373616022c1ba2b4d5af80845cd92 /examples/async/bootstrap.rs | |
parent | 6e31d8f9e46fece348f329763b39b9c6f2741c07 (diff) |
feat: implement async functionality
Diffstat (limited to 'examples/async/bootstrap.rs')
-rw-r--r-- | examples/async/bootstrap.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/async/bootstrap.rs b/examples/async/bootstrap.rs new file mode 100644 index 0000000..b640712 --- /dev/null +++ b/examples/async/bootstrap.rs @@ -0,0 +1,28 @@ +use anyhow::Result; +use syrette::async_di_container::AsyncDIContainer; + +// Concrete implementations +use crate::animals::cat::Cat; +use crate::animals::dog::Dog; +use crate::animals::human::Human; +// +// Interfaces +use crate::interfaces::cat::ICat; +use crate::interfaces::dog::IDog; +use crate::interfaces::human::IHuman; + +pub async fn bootstrap() -> Result<AsyncDIContainer> +{ + let mut di_container = AsyncDIContainer::new(); + + di_container + .bind::<dyn IDog>() + .to::<Dog>()? + .in_singleton_scope() + .await?; + + di_container.bind::<dyn ICat>().to::<Cat>()?; + di_container.bind::<dyn IHuman>().to::<Human>()?; + + Ok(di_container) +} |