Struct runtime_injector::Module[][src]

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

A collection of providers that can be added all at once to an InjectorBuilder. Modules can be used to group together related services and configure the injector in pieces rather than all at once.

For creating a module easily via a domain specific language, see define_module!.

Implementations

impl Module[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 insert_parameter(
    &mut self,
    key: &str,
    value: impl RequestParameter
) -> Option<Box<dyn RequestParameter>>
[src]

Sets the of a value request parameter for requests made by the injector this module is added to. If a parameter has already been set to a value in this module, then that value is returned.

pub fn remove_parameter(
    &mut self,
    key: &str
) -> Option<Box<dyn RequestParameter>>
[src]

Removes and returns the value of a parameter if it has been set.

Trait Implementations

impl Default for Module[src]

fn default() -> Module[src]

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

impl WithArg for Module[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

impl !RefUnwindSafe for Module

impl Send for Module

impl Sync for Module

impl Unpin for Module

impl !UnwindSafe for Module

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.