aboutsummaryrefslogtreecommitdiff
path: root/src/castable_factory
diff options
context:
space:
mode:
Diffstat (limited to 'src/castable_factory')
-rw-r--r--src/castable_factory/mod.rs9
-rw-r--r--src/castable_factory/threadsafe.rs9
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,