aboutsummaryrefslogtreecommitdiff
path: root/src/private/factory.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/private/factory.rs')
-rw-r--r--src/private/factory.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/private/factory.rs b/src/private/factory.rs
new file mode 100644
index 0000000..8b8354d
--- /dev/null
+++ b/src/private/factory.rs
@@ -0,0 +1,23 @@
+use std::marker::Tuple;
+
+use crate::private::cast::CastFrom;
+use crate::ptr::TransientPtr;
+
+/// Interface for a factory.
+pub trait IFactory<Args, ReturnInterface>:
+ Fn<Args, Output = TransientPtr<ReturnInterface>> + CastFrom
+where
+ Args: Tuple,
+ ReturnInterface: 'static + ?Sized,
+{
+}
+
+/// Interface for a threadsafe factory.
+#[cfg(feature = "async")]
+pub trait IThreadsafeFactory<Args, ReturnInterface>:
+ Fn<Args, Output = TransientPtr<ReturnInterface>> + crate::private::cast::CastFromSync
+where
+ Args: Tuple,
+ ReturnInterface: 'static + ?Sized,
+{
+}