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§
Sourcefn dependencies() -> Vec<Dependency>
fn dependencies() -> Vec<Dependency>
The services construct resolves, used to validate the graph at build.
Sourcefn construct(resolver: &Resolver<'_>) -> Result<Self, ResolveError>
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".