From 080cc42bb1da09059dbc35049a7ded0649961e0c Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 29 Aug 2022 20:52:56 +0200 Subject: feat: implement async functionality --- examples/async/bootstrap.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/async/bootstrap.rs (limited to 'examples/async/bootstrap.rs') 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 +{ + let mut di_container = AsyncDIContainer::new(); + + di_container + .bind::() + .to::()? + .in_singleton_scope() + .await?; + + di_container.bind::().to::()?; + di_container.bind::().to::()?; + + Ok(di_container) +} -- cgit v1.2.3-18-g5258