Trait shaku::Provider

source ·
pub trait Provider<M: Module>: 'static {
    type Interface: ?Sized;

    // Required method
    fn provide(module: &M) -> Result<Box<Self::Interface>, Box<dyn Error>>;
}
Expand description

Like Components, providers provide a service by implementing an interface.

Unlike Component, Provider represents a temporary service. Examples include a connection to a remote service or pooled database connection. Because only providers can have other providers as dependencies, services which use these provided services must also be Providers (ex. DB repository, service using a DB repository, etc).

See also the provider getting started guide.

Required Associated Types§

source

type Interface: ?Sized

The trait/interface which this provider implements

Required Methods§

source

fn provide(module: &M) -> Result<Box<Self::Interface>, Box<dyn Error>>

Provides the service, possibly resolving other components/providers to do so.

Object Safety§

This trait is not object safe.

Implementors§