From cde9d4b41a4b37612420ac522bc261147966efa5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 11 Jul 2024 20:48:47 +0200 Subject: refactor: move & rename AnyFactory and AnyThreadsafeFactory traits --- src/castable_factory/mod.rs | 9 +++++++-- src/castable_factory/threadsafe.rs | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/castable_factory') 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 where ReturnInterface: 'static + ?Sized, @@ -32,7 +37,7 @@ where } } -impl AnyFactory +impl AnyCastableFactory for CastableFactory 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 where DIContainerT: 'static, @@ -33,7 +36,7 @@ where } } -impl AnyFactory +impl AnyCastableFactory for ThreadsafeCastableFactory where DIContainerT: 'static, @@ -45,7 +48,7 @@ where } } -impl AnyThreadsafeFactory +impl AnyThreadsafeCastableFactory for ThreadsafeCastableFactory where DIContainerT: 'static, -- cgit v1.2.3-18-g5258