pub trait Factory<Args>:
Send
+ Sync
+ 'static {
type Output: Send + 'static;
// Required methods
fn dependencies(d: &mut Dependencies);
fn call<'a>(
&'a self,
r: &'a Resolver<'a>,
) -> BoxFuture<'a, Result<Self::Output, LookupError>>;
}Expand description
A closure whose parameters are injection points and which returns a future:
|cfg: Dep<DbConfig>| async move { .. }. Implemented for closures of zero to twelve
parameters.
Every parameter needs its type written; an unannotated closure parameter has no type for the
container to read. The output of the future is the binding’s key for singleton, execution
and transient, and its Ok type for the try_ forms.
Required Associated Types§
Required Methods§
Sourcefn dependencies(d: &mut Dependencies)
fn dependencies(d: &mut Dependencies)
The parameters as injection points, in order.
Sourcefn call<'a>(
&'a self,
r: &'a Resolver<'a>,
) -> BoxFuture<'a, Result<Self::Output, LookupError>>
fn call<'a>( &'a self, r: &'a Resolver<'a>, ) -> BoxFuture<'a, Result<Self::Output, LookupError>>
Read every parameter, then call the closure and await its future. A failed read’s error is returned unchanged.
Parameters are read one after another, in the order written, and the first failure ends the call: no read starts after one has failed, and none is left running when the call’s future is dropped.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".