aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-08-05 23:14:06 +0200
committerHampusM <hampus@hampusmat.com>2023-08-05 23:14:06 +0200
commit89c238f9c82ade2d7656e2bee76838a391609a88 (patch)
tree8771a893a9c83b06715c3af0fa2da3cd206b0716 /src/interfaces
parentddc666c55eec968f9a99408f3e3ad0f92d932179 (diff)
refactor!: remove IDependencyHistory
BREAKING CHANGE: IDependencyHistory has been removed as part of an effort to simplify the API. This affects IDIContainer, DIContainer, IAsyncDIContainer, AsyncDIContainer, Injectable, AsyncInjectable, BindingBuilder, AsyncBindingBuilder, BindingScopeConfigurator, BindingWhenConfigurator, AsyncBindingScopeConfigurator, AsyncBindingWhenConfigurator and DependencyHistory
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/async_injectable.rs17
-rw-r--r--src/interfaces/injectable.rs17
2 files changed, 16 insertions, 18 deletions
diff --git a/src/interfaces/async_injectable.rs b/src/interfaces/async_injectable.rs
index d8e7dfc..2364ae1 100644
--- a/src/interfaces/async_injectable.rs
+++ b/src/interfaces/async_injectable.rs
@@ -2,18 +2,19 @@
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;
use crate::private::cast::CastFromArc;
use crate::ptr::TransientPtr;
+use crate::util::use_dependency_history;
+
+use_dependency_history!();
/// Interface for structs that can be injected into or be injected to.
-pub trait AsyncInjectable<DIContainerType, DependencyHistoryType>: CastFromArc
+pub trait AsyncInjectable<DIContainerType>: CastFromArc
where
- DIContainerType: IAsyncDIContainer<DependencyHistoryType>,
- DependencyHistoryType: IDependencyHistory + Send + Sync,
+ DIContainerType: IAsyncDIContainer,
{
/// Resolves the dependencies of the injectable.
///
@@ -21,18 +22,16 @@ where
/// Will return `Err` if resolving the dependencies fails.
fn resolve<'di_container, 'fut>(
di_container: &'di_container Arc<DIContainerType>,
- dependency_history: DependencyHistoryType,
+ dependency_history: DependencyHistory,
) -> BoxFuture<'fut, Result<TransientPtr<Self>, InjectableError>>
where
Self: Sized + 'fut,
'di_container: 'fut;
}
-impl<DIContainerType, DependencyHistoryType> Debug
- for dyn AsyncInjectable<DIContainerType, DependencyHistoryType>
+impl<DIContainerType> Debug for dyn AsyncInjectable<DIContainerType>
where
- DIContainerType: IAsyncDIContainer<DependencyHistoryType>,
- DependencyHistoryType: IDependencyHistory + Send + Sync,
+ DIContainerType: IAsyncDIContainer,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{
diff --git a/src/interfaces/injectable.rs b/src/interfaces/injectable.rs
index b70e13f..82b773a 100644
--- a/src/interfaces/injectable.rs
+++ b/src/interfaces/injectable.rs
@@ -2,17 +2,18 @@
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::private::cast::CastFrom;
use crate::ptr::TransientPtr;
+use crate::util::use_dependency_history;
+
+use_dependency_history!();
/// Interface for structs that can be injected into or be injected to.
-pub trait Injectable<DIContainerType, DependencyHistoryType>: CastFrom
+pub trait Injectable<DIContainerType>: CastFrom
where
- DIContainerType: IDIContainer<DependencyHistoryType>,
- DependencyHistoryType: IDependencyHistory,
+ DIContainerType: IDIContainer,
{
/// Resolves the dependencies of the injectable.
///
@@ -20,17 +21,15 @@ where
/// Will return `Err` if resolving the dependencies fails.
fn resolve(
di_container: &Rc<DIContainerType>,
- dependency_history: DependencyHistoryType,
+ dependency_history: DependencyHistory,
) -> Result<TransientPtr<Self>, InjectableError>
where
Self: Sized;
}
-impl<DIContainerType, DependencyHistoryType> Debug
- for dyn Injectable<DIContainerType, DependencyHistoryType>
+impl<DIContainerType> Debug for dyn Injectable<DIContainerType>
where
- DIContainerType: IDIContainer<DependencyHistoryType>,
- DependencyHistoryType: IDependencyHistory,
+ DIContainerType: IDIContainer,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{