aboutsummaryrefslogtreecommitdiff
path: root/src/di_container/asynchronous/mod.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-10-24 21:53:14 +0200
committerHampusM <hampus@hampusmat.com>2022-10-24 21:53:14 +0200
commit494d905bcbc50b536de892ecb3fa285dc6b8a727 (patch)
tree2dc39c83a10a0badcab2570ee2c640cf8c0a2df4 /src/di_container/asynchronous/mod.rs
parent17fb8ef17d140db1dc887220113f18e6fde79bef (diff)
refactor: rename DI container binding map to DI container storage
Diffstat (limited to 'src/di_container/asynchronous/mod.rs')
-rw-r--r--src/di_container/asynchronous/mod.rs29
1 files changed, 16 insertions, 13 deletions
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<DIContainerBindingMap<dyn IAsyncProvider<Self>>>,
+ binding_storage: Mutex<DIContainerBindingStorage<dyn IAsyncProvider<Self>>>,
}
impl AsyncDIContainer
@@ -134,7 +134,7 @@ impl AsyncDIContainer
pub fn new() -> Arc<Self>
{
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::<Interface>(name)
+ self.binding_storage.lock().await.has::<Interface>(name)
}
async fn set_binding<Interface>(
@@ -206,7 +206,10 @@ impl details::DIContainerInternals for AsyncDIContainer
) where
Interface: 'static + ?Sized,
{
- self.bindings.lock().await.set::<Interface>(name, provider);
+ self.binding_storage
+ .lock()
+ .await
+ .set::<Interface>(name, provider);
}
async fn remove_binding<Interface>(
@@ -216,7 +219,7 @@ impl details::DIContainerInternals for AsyncDIContainer
where
Interface: 'static + ?Sized,
{
- self.bindings.lock().await.remove::<Interface>(name)
+ self.binding_storage.lock().await.remove::<Interface>(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::<Interface>(name)
@@ -459,7 +462,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<dyn subjects_async::IUserManager>(None, Box::new(mock_provider));
@@ -510,7 +513,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<dyn subjects_async::IUserManager>(
@@ -568,7 +571,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<dyn subjects_async::INumber>(None, Box::new(mock_provider));
@@ -632,7 +635,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<dyn subjects_async::INumber>(
@@ -755,7 +758,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<IUserManagerFactory>(None, Box::new(mock_provider));
@@ -866,7 +869,7 @@ mod tests
{
di_container
- .bindings
+ .binding_storage
.lock()
.await
.set::<IUserManagerFactory>(Some("special"), Box::new(mock_provider));