blob: f90b79d9e6c5ed0a1eb4dcb9c81f54b9ab4d5b89 (
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
|
//! Interface for structs that can be injected into or be injected to.
use std::fmt::Debug;
use crate::errors::injectable::InjectableError;
use crate::libs::intertrait::CastFrom;
use crate::ptr::TransientPtr;
use crate::DIContainer;
/// Interface for structs that can be injected into or be injected to.
pub trait Injectable: CastFrom
{
/// Resolves the dependencies of the injectable.
///
/// # Errors
/// Will return `Err` if resolving the dependencies fails.
fn resolve(
di_container: &DIContainer,
dependency_history: Vec<&'static str>,
) -> Result<TransientPtr<Self>, InjectableError>
where
Self: Sized;
}
impl Debug for dyn Injectable
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{
f.write_str("{}")
}
}
|