From 89c238f9c82ade2d7656e2bee76838a391609a88 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 5 Aug 2023 23:14:06 +0200 Subject: 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 --- src/interfaces/async_injectable.rs | 17 ++++++++--------- src/interfaces/injectable.rs | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'src/interfaces') 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: CastFromArc +pub trait AsyncInjectable: CastFromArc where - DIContainerType: IAsyncDIContainer, - 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, - dependency_history: DependencyHistoryType, + dependency_history: DependencyHistory, ) -> BoxFuture<'fut, Result, InjectableError>> where Self: Sized + 'fut, 'di_container: 'fut; } -impl Debug - for dyn AsyncInjectable +impl Debug for dyn AsyncInjectable where - DIContainerType: IAsyncDIContainer, - 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: CastFrom +pub trait Injectable: CastFrom where - DIContainerType: IDIContainer, - 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, - dependency_history: DependencyHistoryType, + dependency_history: DependencyHistory, ) -> Result, InjectableError> where Self: Sized; } -impl Debug - for dyn Injectable +impl Debug for dyn Injectable where - DIContainerType: IDIContainer, - DependencyHistoryType: IDependencyHistory, + DIContainerType: IDIContainer, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -- cgit v1.2.3-18-g5258