Struct ServiceContainer

Source
pub struct ServiceContainer { /* private fields */ }

Trait Implementations§

Source§

impl AsyncServices for ServiceContainer

Source§

fn get_async<'life0, 'async_trait, S>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Arc<S>>> + Send + 'async_trait>>
where S: ?Sized + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Gets the service asynchronously from the service container.
Source§

fn put_async<S>(&mut self, resolver: AsyncResolver<S>)
where S: ?Sized + Send + Sync + 'static,

Puts a asynchronous service to the service container.
Source§

impl Clone for ServiceContainer

Source§

fn clone(&self) -> ServiceContainer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServiceContainer

Source§

fn default() -> ServiceContainer

Returns the “default value” for a type. Read more
Source§

impl Services for ServiceContainer

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.
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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<C> AsyncBindServices for C
where C: AsyncServices,

Source§

fn bind_by_async<Interface, F, Fut>(&mut self, f: F)
where Interface: ?Sized + Send + Sync + 'static, F: Fn(&Self) -> Fut + Send + Sync + 'static, Fut: Future<Output = Option<Arc<Interface>>> + Send + 'static, Self: Send + Sync + 'static,

Source§

impl<C> BindServices for C
where C: Services,

Source§

fn bind<Interface>(&mut self, service: Arc<Interface>)
where Interface: ?Sized + Send + Sync + 'static,

Source§

fn bind_by<Interface, F>(&mut self, f: F)
where Interface: ?Sized + Send + Sync + 'static, F: Fn(&Self) -> Option<Arc<Interface>> + Send + Sync + 'static, Self: 'static,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<C> ConstructServices for C
where C: Services,

Source§

fn construct<S>(&mut self)
where S: Construct<S, Self> + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<C> InjectServices for C
where C: Services,

Source§

fn inject<I>(&mut self, injector: I)
where I: Inject<Self>,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<C> SingletonServices for C
where C: Services,

Source§

fn singleton<S>(&mut self, service: S)
where S: Send + Sync + 'static,

Source§

impl<C> TaggedServices for C
where C: Services,

Source§

fn get_tagged<Tag>(&self) -> Vec<Arc<Tag>>
where Tag: ?Sized + 'static,

Source§

fn put_tagged<Tag>(&mut self, service: Arc<Tag>)
where Tag: ?Sized + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Interface for T
where T: Send + Sync,