Trait abscissa_core::component::Component
source · 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§
Provided Methods§
sourcefn after_config(&mut self, config: &A::Cfg) -> Result<(), FrameworkError>
fn after_config(&mut self, config: &A::Cfg) -> Result<(), FrameworkError>
Lifecycle event called when application configuration should be loaded if it were possible.
sourcefn dependencies(&self) -> Iter<'_, Id>
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.
sourcefn register_dependency(
&mut self,
handle: Handle,
dependency: &mut dyn Component<A>
) -> Result<(), FrameworkError>
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”)
sourcefn before_shutdown(&self, kind: Shutdown) -> Result<(), FrameworkError>
fn before_shutdown(&self, kind: Shutdown) -> Result<(), FrameworkError>
Perform any tasks which should occur before the app exits
Trait Implementations§
source§impl<A> PartialEq<Box<dyn Component<A> + 'static, Global>> for Box<dyn Component<A>>where
A: Application,
impl<A> PartialEq<Box<dyn Component<A> + 'static, Global>> for Box<dyn Component<A>>where
A: Application,
source§impl<A> PartialOrd<Box<dyn Component<A> + 'static, Global>> for Box<dyn Component<A>>where
A: Application,
impl<A> PartialOrd<Box<dyn Component<A> + 'static, Global>> for Box<dyn Component<A>>where
A: Application,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more