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/castable_factory | |
parent | ebd6d71e7ef357c310264bf55001498928fb94c7 (diff) |
refactor: move & rename AnyFactory and AnyThreadsafeFactory traits
Diffstat (limited to 'src/castable_factory')
-rw-r--r-- | src/castable_factory/mod.rs | 9 | ||||
-rw-r--r-- | src/castable_factory/threadsafe.rs | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/castable_factory/mod.rs b/src/castable_factory/mod.rs index 196dc14..0cb2127 100644 --- a/src/castable_factory/mod.rs +++ b/src/castable_factory/mod.rs @@ -1,12 +1,17 @@ use std::any::{type_name, Any}; use std::fmt::Debug; -use crate::any_factory::AnyFactory; use crate::ptr::TransientPtr; #[cfg(feature = "async")] pub mod threadsafe; +/// Interface for any castable factory. +pub trait AnyCastableFactory: Any + Debug +{ + fn as_any(&self) -> &dyn Any; +} + pub struct CastableFactory<ReturnInterface, DIContainerT> where ReturnInterface: 'static + ?Sized, @@ -32,7 +37,7 @@ where } } -impl<ReturnInterface, DIContainerT> AnyFactory +impl<ReturnInterface, DIContainerT> AnyCastableFactory for CastableFactory<ReturnInterface, DIContainerT> where ReturnInterface: 'static + ?Sized, diff --git a/src/castable_factory/threadsafe.rs b/src/castable_factory/threadsafe.rs index 5935d75..8b1e66d 100644 --- a/src/castable_factory/threadsafe.rs +++ b/src/castable_factory/threadsafe.rs @@ -1,9 +1,12 @@ use std::any::{type_name, Any}; use std::fmt::Debug; -use crate::any_factory::{AnyFactory, AnyThreadsafeFactory}; +use crate::castable_factory::AnyCastableFactory; use crate::ptr::TransientPtr; +/// Interface for any threadsafe castable factory. +pub trait AnyThreadsafeCastableFactory: AnyCastableFactory + Send + Sync + Debug {} + pub struct ThreadsafeCastableFactory<ReturnInterface, DIContainerT> where DIContainerT: 'static, @@ -33,7 +36,7 @@ where } } -impl<ReturnInterface, DIContainerT> AnyFactory +impl<ReturnInterface, DIContainerT> AnyCastableFactory for ThreadsafeCastableFactory<ReturnInterface, DIContainerT> where DIContainerT: 'static, @@ -45,7 +48,7 @@ where } } -impl<ReturnInterface, DIContainerT> AnyThreadsafeFactory +impl<ReturnInterface, DIContainerT> AnyThreadsafeCastableFactory for ThreadsafeCastableFactory<ReturnInterface, DIContainerT> where DIContainerT: 'static, |