diff options
| author | HampusM <hampus@hampusmat.com> | 2022-10-29 14:38:51 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2022-10-29 14:40:11 +0200 | 
| commit | aa548ded39c7ba1927019c748c359523b21d59e8 (patch) | |
| tree | 779d104f85009dd831e6af6e7a523258a1ab5be9 /src/interfaces/injectable.rs | |
| parent | da94fd3b7dd2265f10957d0f5276881beb057d82 (diff) | |
refactor!: add dependency history type
BREAKING CHANGE: Binding builders & configurators now take dependency history type arguments, the DetectedCircular variant of InjectableError now contains a dependency history field & the injectable traits take dependency history instead of a Vec
Diffstat (limited to 'src/interfaces/injectable.rs')
| -rw-r--r-- | src/interfaces/injectable.rs | 14 | 
1 files changed, 9 insertions, 5 deletions
| 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      { | 
