diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/async_injectable.rs | 14 | ||||
-rw-r--r-- | src/interfaces/injectable.rs | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/interfaces/async_injectable.rs b/src/interfaces/async_injectable.rs index fb7f8ba..4e614a3 100644 --- a/src/interfaces/async_injectable.rs +++ b/src/interfaces/async_injectable.rs @@ -2,6 +2,7 @@ use std::fmt::Debug; use std::sync::Arc; +use crate::dependency_history::IDependencyHistory; use crate::di_container::asynchronous::IAsyncDIContainer; use crate::errors::injectable::InjectableError; use crate::future::BoxFuture; @@ -9,9 +10,10 @@ use crate::libs::intertrait::CastFromSync; use crate::ptr::TransientPtr; /// Interface for structs that can be injected into or be injected to. -pub trait AsyncInjectable<DIContainerType>: CastFromSync +pub trait AsyncInjectable<DIContainerType, DependencyHistoryType>: CastFromSync where - DIContainerType: IAsyncDIContainer, + DIContainerType: IAsyncDIContainer<DependencyHistoryType>, + DependencyHistoryType: IDependencyHistory + Send + Sync, { /// Resolves the dependencies of the injectable. /// @@ -19,16 +21,18 @@ where /// Will return `Err` if resolving the dependencies fails. fn resolve<'di_container, 'fut>( di_container: &'di_container Arc<DIContainerType>, - dependency_history: Vec<&'static str>, + dependency_history: DependencyHistoryType, ) -> BoxFuture<'fut, Result<TransientPtr<Self>, InjectableError>> where Self: Sized + 'fut, 'di_container: 'fut; } -impl<DIContainerType> Debug for dyn AsyncInjectable<DIContainerType> +impl<DIContainerType, DependencyHistoryType> Debug + for dyn AsyncInjectable<DIContainerType, DependencyHistoryType> where - DIContainerType: IAsyncDIContainer, + DIContainerType: IAsyncDIContainer<DependencyHistoryType>, + DependencyHistoryType: IDependencyHistory + Send + Sync, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/src/interfaces/injectable.rs b/src/interfaces/injectable.rs index 132935d..6130d2b 100644 --- a/src/interfaces/injectable.rs +++ b/src/interfaces/injectable.rs @@ -2,15 +2,17 @@ use std::fmt::Debug; use std::rc::Rc; +use crate::dependency_history::IDependencyHistory; use crate::di_container::blocking::IDIContainer; use crate::errors::injectable::InjectableError; use crate::libs::intertrait::CastFrom; use crate::ptr::TransientPtr; /// Interface for structs that can be injected into or be injected to. -pub trait Injectable<DIContainerType>: CastFrom +pub trait Injectable<DIContainerType, DependencyHistoryType>: CastFrom where - DIContainerType: IDIContainer, + DIContainerType: IDIContainer<DependencyHistoryType>, + DependencyHistoryType: IDependencyHistory, { /// Resolves the dependencies of the injectable. /// @@ -18,15 +20,17 @@ where /// Will return `Err` if resolving the dependencies fails. fn resolve( di_container: &Rc<DIContainerType>, - dependency_history: Vec<&'static str>, + dependency_history: DependencyHistoryType, ) -> Result<TransientPtr<Self>, InjectableError> where Self: Sized; } -impl<DIContainerType> Debug for dyn Injectable<DIContainerType> +impl<DIContainerType, DependencyHistoryType> Debug + for dyn Injectable<DIContainerType, DependencyHistoryType> where - DIContainerType: IDIContainer, + DIContainerType: IDIContainer<DependencyHistoryType>, + DependencyHistoryType: IDependencyHistory, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |