pub trait Component<A>: AsAny + Debug + Send + Syncwhere
    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> { ... } }
Expand description

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§

Identifier for this component.

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

Version of this component

Provided Methods§

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

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.

Register a dependency of this component (a.k.a. “dependency injection”)

Perform any tasks which should occur before the app exits

Trait Implementations§

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Implementors§