Struct runtime_injector::InjectorBuilder[][src]

pub struct InjectorBuilder { /* fields omitted */ }
Expand description

A builder for an Injector.

Implementations

impl InjectorBuilder[src]

pub fn provide<P: Provider>(&mut self, provider: P)[src]

Assigns the provider for a service type. Multiple providers can be registered for a service.

pub fn add_provider(&mut self, provider: Box<dyn Provider>)[src]

Adds a provider to the injector.

pub fn remove_providers(
    &mut self,
    service_info: ServiceInfo
) -> Option<Vec<Box<dyn Provider>>>
[src]

Removes all providers for a service type.

#[must_use]
pub fn root_info(&self) -> &RequestInfo
[src]

Borrows the root RequestInfo that will be used by calls to Injector::get().

#[must_use]
pub fn root_info_mut(&mut self) -> &mut RequestInfo
[src]

Mutably borrows the root RequestInfo that will be used by calls to Injector::get().

pub fn add_module(&mut self, module: Module)[src]

Adds all the providers registered in a module. This may cause multiple providers to be registered for the same service.

If any conflicting request parameters have been set before adding this module, they are overridden.

#[must_use]
pub fn build(self) -> Injector
[src]

Builds the injector.

Trait Implementations

impl Default for InjectorBuilder[src]

fn default() -> InjectorBuilder[src]

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

impl WithArg for InjectorBuilder[src]

fn with_arg<S: Service, T: Service + AsAny + Clone>(
    &mut self,
    value: T
) -> Option<Box<dyn RequestParameter>>
[src]

Adds an argument for a service. See the docs for Arg<T>.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.