Trait runtime_injector::Interface[][src]

pub trait Interface: Service {
    fn resolve(
        injector: &mut Injector,
        implementation: Option<ServiceInfo>
    ) -> InjectResult<Svc<Self>>; }

Indicates that a type can resolve services. The most basic implementation of this trait is that each sized service type can resolve itself. This is done by requesting the exact implementation of itself from the injector. However, the injector cannot provide exact implementations for dynamic types (dyn Trait). For this reason, any interfaces using traits must be declared explicitly before use. This trait should usually be implemented by the interface! macro.

Required methods

fn resolve(
    injector: &mut Injector,
    implementation: Option<ServiceInfo>
) -> InjectResult<Svc<Self>>
[src]

Attempts to resolve a service which implements this interface. If an implementation type is provided, this should attempt to return an instance of that type. If it cannot, then this should return an error. However, it is not unsound to return the wrong type. It is only unsafe for code to rely on that exact type being returned in an unsafe manner.

Loading content...

Implementors

impl<T: Service> Interface for T[src]

Loading content...