Services

Trait Services 

Source
pub trait Services:
    Sized
    + Send
    + Sync {
    // Required methods
    fn has<S>(&self) -> bool
       where S: ?Sized + 'static;
    fn get<S>(&self) -> Option<Arc<S>>
       where S: ?Sized + Send + Sync + 'static;
    fn put<S, R>(&mut self, resolver: R)
       where S: ?Sized + Send + Sync + 'static,
             R: Resolve<S, Self> + 'static;

    // Provided method
    fn replace<S, F>(&mut self, f: F)
       where S: Send + Sync + 'static,
             F: FnOnce(Option<&S>) -> S { ... }
}

Required Methods§

Source

fn has<S>(&self) -> bool
where S: ?Sized + 'static,

Returns whether the service container has the specified service or not.

Source

fn get<S>(&self) -> Option<Arc<S>>
where S: ?Sized + Send + Sync + 'static,

Gets the service from the service container. Asynchronous services can not be retrieved using this method. Use [AsyncServices::get] for resolving a service asynchronously.

Source

fn put<S, R>(&mut self, resolver: R)
where S: ?Sized + Send + Sync + 'static, R: Resolve<S, Self> + 'static,

Puts a service to the service container.

Provided Methods§

Source

fn replace<S, F>(&mut self, f: F)
where S: Send + Sync + 'static, F: FnOnce(Option<&S>) -> S,

Replaces the service in the container by the mutation function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§