[][src]Trait abscissa_core::component::Component

pub trait Component<A>: AsAny + Debug + Send + Sync where
    A: Application
{ fn id(&self) -> Id;
fn version(&self) -> Version; fn after_config(&mut self, config: &A::Cfg) -> Result<(), FrameworkError> { ... }
fn dependencies(&self) -> Iter<Id> { ... }
fn register_dependency(
        &mut self,
        handle: Handle,
        dependency: &mut dyn Component<A>
    ) -> Result<(), FrameworkError> { ... }
fn before_shutdown(&self, kind: Shutdown) -> Result<(), FrameworkError> { ... } }

Application components.

Components are Abscissa's primary extension mechanism, and are aware of the application lifecycle. They are owned by the application as boxed trait objects in a runtime type registry which is aware of a dependency ordering and can (potentially in the future) support runtime reinitialization.

During application initialization, callbacks are sent to all components upon events like application configuration being loaded. The register_dependency callback is called for each dependency returned by the dependencies method.

Additionally, they receive a callback prior to application shutdown.

Custom Derive

The main intended way to impl this trait is by using the built-in custom derive functionality.

use abscissa_core::Component;

#[derive(Component, Debug)]
pub struct MyComponent {}

This will automatically implement the entire trait for you.

Required methods

fn id(&self) -> Id

Identifier for this component.

These are the Rust path (e.g. crate_name:foo::Foo) by convention.

fn version(&self) -> Version

Version of this component

Loading content...

Provided methods

fn after_config(&mut self, config: &A::Cfg) -> Result<(), FrameworkError>

Lifecycle event called when application configuration should be loaded if it were possible.

fn dependencies(&self) -> Iter<Id>

Names of the components this component depends on.

After this app's after_config callback is fired, the register_dependency callback below will be fired for each of these.

fn register_dependency(
    &mut self,
    handle: Handle,
    dependency: &mut dyn Component<A>
) -> Result<(), FrameworkError>

Register a dependency of this component (a.k.a. "dependency injection")

fn before_shutdown(&self, kind: Shutdown) -> Result<(), FrameworkError>

Perform any tasks which should occur before the app exits

Loading content...

Implementors

impl<A> Component<A> for Terminal where
    A: Application
[src]

fn id(&self) -> Id[src]

Identifier for this component

fn version(&self) -> Version[src]

Version of this component

impl<A> Component<A> for Tracing where
    A: Application
[src]

fn id(&self) -> Id[src]

Identifier for this component

fn version(&self) -> Version[src]

Version of this component

Loading content...