Resolver

Trait Resolver 

Source
pub trait Resolver<'a, Cont, T, Infer> {
    // Required method
    fn resolve(&'a self) -> T;
}
Expand description

This trait is used to resolve some object from service provider. Generic T used only to avoid absence of specialization and for working of type inference. You must implement it yourself only when you implement your own version of container.

For common usage you need only import it from steloc, and calling resolve method when you need to get a service from ServiceProvider.

Example:

use steloc::*;

struct Foo(u8);

#[inject]
fn new_foo() -> Foo {
    Foo(5)
}

let sp = ServiceProvider::new()
    .add_transient::<Foo>();

let foo: Foo = sp.resolve();

assert_eq!(foo.0, 5)

Required Methods§

Source

fn resolve(&'a self) -> T

Implementors§

Source§

impl<'this, 'cont, Cont, T, U, SP, Index, Deps, Infer> Resolver<'this, &'cont ConvertContainer<Cont, T, U>, U, (Index, Deps, Infer)> for SP
where SP: SelectContainer<'this, &'cont ConvertContainer<Cont, T, U>, Index> + GetDependencies<'this, Deps, Infer>, ConvertContainer<Cont, T, U>: ResolveContainer<'cont, U, Deps>, Cont: 'cont, T: Into<U> + 'cont, U: 'cont, Deps: 'cont,

Source§

impl<'this, 'cont, T, SP, Index> Resolver<'this, &'cont InstanceContainer<T>, &'cont T, Index> for SP
where SP: SelectContainer<'this, &'cont InstanceContainer<T>, Index>, InstanceContainer<T>: ResolveContainer<'cont, &'cont T, HNil>,

Source§

impl<'this, 'cont, T, SP, Index> Resolver<'this, &'cont InstanceContainer<T>, T, Index> for SP
where SP: SelectContainer<'this, &'cont InstanceContainer<T>, Index>, InstanceContainer<T>: ResolveContainer<'cont, &'cont T, HNil>, T: DependencyClone + 'cont,

Source§

impl<'this, 'cont, T, SP, Index, Deps, Infer> Resolver<'this, &'cont SingletonContainer<T>, &'cont T, (Index, Deps, Infer)> for SP
where SP: GetDependencies<'this, Deps, Infer> + SelectContainer<'this, &'cont SingletonContainer<T>, Index>, SingletonContainer<T>: ResolveContainer<'cont, &'cont T, Deps>, T: Dependency<Deps> + 'cont, Deps: 'cont,

Source§

impl<'this, 'cont, T, SP, Index, Deps, Infer> Resolver<'this, &'cont SingletonContainer<T>, T, (Index, Deps, Infer)> for SP
where SP: GetDependencies<'this, Deps, Infer> + SelectContainer<'this, &'cont SingletonContainer<T>, Index>, SingletonContainer<T>: ResolveContainer<'cont, &'cont T, Deps>, T: Dependency<Deps> + DependencyClone + 'cont, Deps: 'cont,

Source§

impl<'this, 'cont, T, SP, Index, Deps, Infer> Resolver<'this, &'cont TransientContainer<T>, T, (Index, Deps, Infer)> for SP
where SP: SelectContainer<'this, &'cont TransientContainer<T>, Index> + GetDependencies<'this, Deps, Infer>, TransientContainer<T>: ResolveContainer<'cont, T, Deps>, T: Dependency<Deps> + 'cont,