diff options
author | HampusM <hampus@hampusmat.com> | 2023-10-04 12:51:06 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-10-04 12:52:22 +0200 |
commit | 0f2756536e8fc311119da2af5b4dcc33f41bec6e (patch) | |
tree | 0964efe0eaf855017c67fae52da8672a47becc65 /src/provider/async.rs | |
parent | c936439bfac9e35958f685a52abb51d781e70a7c (diff) |
refactor!: remove factory & declare_default_factory macros
BREAKING CHANGE: The factory and the declare_default_factory macros have been removed. They are no longer needed to use factories
Diffstat (limited to 'src/provider/async.rs')
-rw-r--r-- | src/provider/async.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/provider/async.rs b/src/provider/async.rs index a3db57e..3875363 100644 --- a/src/provider/async.rs +++ b/src/provider/async.rs @@ -16,21 +16,15 @@ pub enum AsyncProvidable<DIContainerT> Singleton(ThreadsafeSingletonPtr<dyn AsyncInjectable<DIContainerT>>), #[cfg(feature = "factory")] Factory( - crate::ptr::ThreadsafeFactoryPtr< - dyn crate::private::any_factory::AnyThreadsafeFactory, - >, + crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, ), #[cfg(feature = "factory")] DefaultFactory( - crate::ptr::ThreadsafeFactoryPtr< - dyn crate::private::any_factory::AnyThreadsafeFactory, - >, + crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, ), #[cfg(feature = "factory")] AsyncDefaultFactory( - crate::ptr::ThreadsafeFactoryPtr< - dyn crate::private::any_factory::AnyThreadsafeFactory, - >, + crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, ), } @@ -188,9 +182,8 @@ pub enum AsyncFactoryVariant #[cfg(feature = "factory")] pub struct AsyncFactoryProvider { - factory: crate::ptr::ThreadsafeFactoryPtr< - dyn crate::private::any_factory::AnyThreadsafeFactory, - >, + factory: + crate::ptr::ThreadsafeFactoryPtr<dyn crate::any_factory::AnyThreadsafeFactory>, variant: AsyncFactoryVariant, } @@ -199,7 +192,7 @@ impl AsyncFactoryProvider { pub fn new( factory: crate::ptr::ThreadsafeFactoryPtr< - dyn crate::private::any_factory::AnyThreadsafeFactory, + dyn crate::any_factory::AnyThreadsafeFactory, >, variant: AsyncFactoryVariant, ) -> Self @@ -307,12 +300,22 @@ mod tests #[cfg(feature = "factory")] async fn async_factory_provider_works() { - use crate::private::any_factory::AnyThreadsafeFactory; + use std::any::Any; + + use crate::any_factory::{AnyFactory, AnyThreadsafeFactory}; use crate::ptr::ThreadsafeFactoryPtr; #[derive(Debug)] struct FooFactory; + impl AnyFactory for FooFactory + { + fn as_any(&self) -> &dyn Any + { + self + } + } + impl AnyThreadsafeFactory for FooFactory {} let factory_provider = AsyncFactoryProvider::new( |