blob: 4c1848765258d3178b13a529b2b6d7d208aeca6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//! Interface for structs that can be injected into or be injected to.
use std::fmt::Debug;
use crate::errors::injectable::InjectableError;
use crate::future::BoxFuture;
use crate::private::cast::CastFromArc;
use crate::ptr::TransientPtr;
use crate::util::use_double;
use_double!(crate::dependency_history::DependencyHistory);
/// Interface for structs that can be injected into or be injected to.
pub trait AsyncInjectable<DIContainerT>: CastFromArc
{
/// Resolves the dependencies of the injectable.
///
/// # Errors
/// Will return `Err` if resolving the dependencies fails.
fn resolve<'di_container, 'fut>(
di_container: &'di_container DIContainerT,
dependency_history: DependencyHistory,
) -> BoxFuture<'fut, Result<TransientPtr<Self>, InjectableError>>
where
Self: Sized + 'fut,
'di_container: 'fut;
}
impl<DIContainerT> Debug for dyn AsyncInjectable<DIContainerT>
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{
f.write_str("{}")
}
}
|