Trait shaku::HasComponent[][src]

pub trait HasComponent<I: Interface + ?Sized>: ModuleInterface {
    fn build_component(context: &mut ModuleBuildContext<Self>) -> Arc<I>
    where
        Self: Module + Sized
;
fn resolve(&self) -> Arc<I>;
fn resolve_ref(&self) -> &I; }

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
[src]

Build the component during module build. Usually this involves calling ModuleBuildContext::build_component with the implementation.

fn resolve(&self) -> Arc<I>[src]

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[src]

Get a reference to the component.

Example

let foo: &dyn Foo = module.resolve_ref();
Loading content...

Implementors

Loading content...