aboutsummaryrefslogtreecommitdiff
path: root/src/private/factory.rs
blob: c1672e149768be620c47e86138d68bdcd02d39c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#[cfg(feature = "async")]
use std::sync::Arc;

use crate::private::cast::CastFrom;
use crate::ptr::TransientPtr;

/// Interface for a factory.
pub trait IFactory<ReturnInterface, DIContainerT>: CastFrom
where
    ReturnInterface: 'static + ?Sized,
{
    fn call(&self, di_container: &DIContainerT) -> TransientPtr<ReturnInterface>;
}

/// Interface for a threadsafe factory.
#[cfg(feature = "async")]
pub trait IThreadsafeFactory<ReturnInterface, DIContainerT>:
    crate::private::cast::CastFromArc
where
    ReturnInterface: 'static + ?Sized,
{
    fn call(&self, di_container: Arc<DIContainerT>) -> TransientPtr<ReturnInterface>;
}