Struct he_di::Container
[−]
[src]
pub struct Container { /* fields omitted */ }
Struct containing all the registered components and associated with a specific set of parameters
Methods
impl Container
[src]
fn resolve<T: ?Sized + 'static>(&mut self) -> DIResult<Box<T>>
Get an instance of the component registered with the trait T
Current implementation removes all information related to the component
(i.e. can't be used as a builder/factory of Components)
Sample usage:
rust, ignore he_di::container::Container::resolve::<MyTrait>();
fn resolve_ref<T: ?Sized + 'static>(&mut self) -> DIResult<&T>
Get a reference of a component registered with the trait T
This component can later be resolved with any other resolve method
Sample usage:
rust, ignore he_di::container::Container::resolve_ref::<MyTrait>();
fn resolve_mut<T: ?Sized + 'static>(&mut self) -> DIResult<&mut T>
Get a mutable reference of a component registered with the trait T
This component can later be resolved with any other resolve method
Sample usage:
rust, ignore he_di::container::Container::resolve_mut::<MyTrait>();
fn with_named_parameter<T: ?Sized + 'static, V: Any>(
&mut self,
name: &str,
value: V
) -> &mut Self
&mut self,
name: &str,
value: V
) -> &mut Self
Add a new named parameter for an already registered Component T
If T
wasn't previously registered, does nothing
fn with_typed_parameter<T: ?Sized + 'static, V: Any>(
&mut self,
value: V
) -> &mut Self
&mut self,
value: V
) -> &mut Self
Add a new typed parameter for an already registered Component T
If T
wasn't previously registered, does nothing