Skip to main content

Service

Trait Service 

Source
pub trait Service:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn dependencies() -> Vec<Dependency>;
    fn construct(resolver: &Resolver<'_>) -> Result<Self, ResolveError>;
}
Expand description

A type the container can construct.

Usually derived with #[derive(Service)]. Constructors must not block on other threads that resolve services from the same container: construction of cached instances is serialised per container and per scope.

Required Methods§

Source

fn dependencies() -> Vec<Dependency>

The services construct resolves, used to validate the graph at build.

Source

fn construct(resolver: &Resolver<'_>) -> Result<Self, ResolveError>

Builds the service, resolving its dependencies through resolver.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§