//! Interface for structs that can be injected into or be injected to. 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::libs::intertrait::CastFromSync; use crate::ptr::TransientPtr; /// Interface for structs that can be injected into or be injected to. pub trait AsyncInjectable: CastFromSync where DIContainerType: IAsyncDIContainer, DependencyHistoryType: IDependencyHistory + Send + Sync, { /// Resolves the dependencies of the injectable. /// /// # Errors /// Will return `Err` if resolving the dependencies fails. fn resolve<'di_container, 'fut>( di_container: &'di_container Arc, dependency_history: DependencyHistoryType, ) -> BoxFuture<'fut, Result, InjectableError>> where Self: Sized + 'fut, 'di_container: 'fut; } impl Debug for dyn AsyncInjectable where DIContainerType: IAsyncDIContainer, DependencyHistoryType: IDependencyHistory + Send + Sync, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str("{}") } }