diff options
author | HampusM <hampus@hampusmat.com> | 2024-07-11 20:48:47 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-07-11 20:48:47 +0200 |
commit | cde9d4b41a4b37612420ac522bc261147966efa5 (patch) | |
tree | 0a3e84e3e8ef622f3db5b7802c36ad29711ee5cc /src/provider | |
parent | ebd6d71e7ef357c310264bf55001498928fb94c7 (diff) |
refactor: move & rename AnyFactory and AnyThreadsafeFactory traits
Diffstat (limited to 'src/provider')
-rw-r--r-- | src/provider/async.rs | 26 | ||||
-rw-r--r-- | src/provider/blocking.rs | 14 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/provider/async.rs b/src/provider/async.rs index 3875363..6ccb082 100644 --- a/src/provider/async.rs +++ b/src/provider/async.rs @@ -16,15 +16,21 @@ pub enum AsyncProvidable<DIContainerT> Singleton(ThreadsafeSingletonPtr<dyn AsyncInjectable<DIContainerT>>), #[cfg(feature = "factory")] Factory( - crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, + crate::ptr::ThreadsafeFactoryPtr< + dyn crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory, + >, ), #[cfg(feature = "factory")] DefaultFactory( - crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, + crate::ptr::ThreadsafeFactoryPtr< + dyn crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory, + >, ), #[cfg(feature = "factory")] AsyncDefaultFactory( - crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, + crate::ptr::ThreadsafeFactoryPtr< + dyn crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory, + >, ), } @@ -182,8 +188,9 @@ pub enum AsyncFactoryVariant #[cfg(feature = "factory")] pub struct AsyncFactoryProvider { - factory: - crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, + factory: crate::ptr::ThreadsafeFactoryPtr< + dyn crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory, + >, variant: AsyncFactoryVariant, } @@ -192,7 +199,7 @@ impl AsyncFactoryProvider { pub fn new( factory: crate::ptr::ThreadsafeFactoryPtr< - dyn crate::any_factory::AnyThreadsafeFactory, + dyn crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory, >, variant: AsyncFactoryVariant, ) -> Self @@ -302,13 +309,14 @@ mod tests { use std::any::Any; - use crate::any_factory::{AnyFactory, AnyThreadsafeFactory}; + use crate::castable_factory::threadsafe::AnyThreadsafeCastableFactory; + use crate::castable_factory::AnyCastableFactory; use crate::ptr::ThreadsafeFactoryPtr; #[derive(Debug)] struct FooFactory; - impl AnyFactory for FooFactory + impl AnyCastableFactory for FooFactory { fn as_any(&self) -> &dyn Any { @@ -316,7 +324,7 @@ mod tests } } - impl AnyThreadsafeFactory for FooFactory {} + impl AnyThreadsafeCastableFactory for FooFactory {} let factory_provider = AsyncFactoryProvider::new( ThreadsafeFactoryPtr::new(FooFactory), diff --git a/src/provider/blocking.rs b/src/provider/blocking.rs index bde3be5..65e315d 100644 --- a/src/provider/blocking.rs +++ b/src/provider/blocking.rs @@ -13,9 +13,11 @@ pub enum Providable<DIContainerType> Transient(TransientPtr<dyn Injectable<DIContainerType>>), Singleton(SingletonPtr<dyn Injectable<DIContainerType>>), #[cfg(feature = "factory")] - Factory(crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>), + Factory(crate::ptr::FactoryPtr<dyn crate::castable_factory::AnyCastableFactory>), #[cfg(feature = "factory")] - DefaultFactory(crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>), + DefaultFactory( + crate::ptr::FactoryPtr<dyn crate::castable_factory::AnyCastableFactory>, + ), } #[cfg_attr(test, mockall::automock)] @@ -108,7 +110,7 @@ where #[cfg(feature = "factory")] pub struct FactoryProvider { - factory: crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>, + factory: crate::ptr::FactoryPtr<dyn crate::castable_factory::AnyCastableFactory>, is_default_factory: bool, } @@ -116,7 +118,7 @@ pub struct FactoryProvider impl FactoryProvider { pub fn new( - factory: crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>, + factory: crate::ptr::FactoryPtr<dyn crate::castable_factory::AnyCastableFactory>, is_default_factory: bool, ) -> Self { @@ -198,13 +200,13 @@ mod tests { use std::any::Any; - use crate::any_factory::AnyFactory; + use crate::castable_factory::AnyCastableFactory; use crate::ptr::FactoryPtr; #[derive(Debug)] struct FooFactory; - impl AnyFactory for FooFactory + impl AnyCastableFactory for FooFactory { fn as_any(&self) -> &dyn Any { |