[−][src]Trait shaku::HasComponent
Indicates that a module contains a component which implements the interface.
Required methods
fn build_component(context: &mut ModuleBuildContext<Self>) -> Arc<I> where
Self: Module + Sized,
Self: Module + Sized,
Build the component during module build. Usually this involves calling
ModuleBuildContext::build_component
with the implementation.
fn resolve(&self) -> Arc<I>
Get a reference to the component. The ownership of the component is
shared via Arc
.
Example
let foo: Arc<dyn Foo> = module.resolve();
fn resolve_ref(&self) -> &I
fn resolve_mut(&mut self) -> Option<&mut I>
Get a mutable reference to the component.
If the component is jointly owned (an Arc<I>
reference to the
component exists outside of this module), then None
will be returned
as it is unsafe to take a mutable reference without exclusive ownership
of the component.
Example
let foo: &mut dyn Foo = module.resolve_mut().unwrap();