From 494d905bcbc50b536de892ecb3fa285dc6b8a727 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 24 Oct 2022 21:53:14 +0200 Subject: refactor: rename DI container binding map to DI container storage --- src/di_container/asynchronous/mod.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/di_container/asynchronous') diff --git a/src/di_container/asynchronous/mod.rs b/src/di_container/asynchronous/mod.rs index 14e6abe..128fbbe 100644 --- a/src/di_container/asynchronous/mod.rs +++ b/src/di_container/asynchronous/mod.rs @@ -58,7 +58,7 @@ use async_trait::async_trait; use tokio::sync::Mutex; use crate::di_container::asynchronous::binding::builder::AsyncBindingBuilder; -use crate::di_container::binding_map::DIContainerBindingMap; +use crate::di_container::binding_storage::DIContainerBindingStorage; use crate::errors::async_di_container::AsyncDIContainerError; use crate::future::BoxFuture; use crate::libs::intertrait::cast::error::CastError; @@ -124,7 +124,7 @@ pub trait IAsyncDIContainer: /// Dependency injection container. pub struct AsyncDIContainer { - bindings: Mutex>>, + binding_storage: Mutex>>, } impl AsyncDIContainer @@ -134,7 +134,7 @@ impl AsyncDIContainer pub fn new() -> Arc { Arc::new(Self { - bindings: Mutex::new(DIContainerBindingMap::new()), + binding_storage: Mutex::new(DIContainerBindingStorage::new()), }) } } @@ -196,7 +196,7 @@ impl details::DIContainerInternals for AsyncDIContainer where Interface: ?Sized + 'static, { - self.bindings.lock().await.has::(name) + self.binding_storage.lock().await.has::(name) } async fn set_binding( @@ -206,7 +206,10 @@ impl details::DIContainerInternals for AsyncDIContainer ) where Interface: 'static + ?Sized, { - self.bindings.lock().await.set::(name, provider); + self.binding_storage + .lock() + .await + .set::(name, provider); } async fn remove_binding( @@ -216,7 +219,7 @@ impl details::DIContainerInternals for AsyncDIContainer where Interface: 'static + ?Sized, { - self.bindings.lock().await.remove::(name) + self.binding_storage.lock().await.remove::(name) } } @@ -349,7 +352,7 @@ impl AsyncDIContainer let provider; { - let bindings_lock = self.bindings.lock().await; + let bindings_lock = self.binding_storage.lock().await; provider = bindings_lock .get::(name) @@ -459,7 +462,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::(None, Box::new(mock_provider)); @@ -510,7 +513,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::( @@ -568,7 +571,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::(None, Box::new(mock_provider)); @@ -632,7 +635,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::( @@ -755,7 +758,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::(None, Box::new(mock_provider)); @@ -866,7 +869,7 @@ mod tests { di_container - .bindings + .binding_storage .lock() .await .set::(Some("special"), Box::new(mock_provider)); -- cgit v1.2.3-18-g5258