Trait nuts_container::ServiceFactory

source ·
pub trait ServiceFactory<B: Backend> {
    type Service: Service<B>;
    type Err: From<Error<B>>;

    // Required methods
    fn create(container: Container<B>) -> Result<Self::Service, Self::Err>;
    fn open(container: Container<B>) -> Result<Self::Service, Self::Err>;
}
Expand description

Factory used to instantiate a service.

Required Associated Types§

source

type Service: Service<B>

The service

source

type Err: From<Error<B>>

Error returned by Self::open and Self::create.

It must be possible to put an Error instance into this error.

Required Methods§

source

fn create(container: Container<B>) -> Result<Self::Service, Self::Err>

Create a service instance.

Called by Container::create_service the method should create a new Self::Service instance. The created container is passed to this method.

source

fn open(container: Container<B>) -> Result<Self::Service, Self::Err>

Open a service.

Called by Container::open_service the method should open an existing Self::Service instance. The opened container is passed to this method.

Object Safety§

This trait is not object safe.

Implementors§