aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/injectable.rs
blob: e6e4ced0e51dccb4e160945187a67af94f688060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! Interface for structs that can be injected into or be injected to.
use crate::errors::injectable::ResolveError;
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>,
    ) -> error_stack::Result<TransientPtr<Self>, ResolveError>
    where
        Self: Sized;
}