pub trait ApplicationPart {
type Error: Error + Send;
// Required method
fn run(
&mut self,
cancellation_token: CancellationToken,
) -> impl Future<Output = Result<(), Self::Error>> + Send + '_;
// Provided methods
fn name() -> Cow<'static, str> { ... }
fn before_startup(
&mut self,
cancellation_token: CancellationToken,
) -> impl Future<Output = Result<(), Self::Error>> + Send + '_ { ... }
fn before_shutdown(
&mut self,
cancellation_token: CancellationToken,
) -> impl Future<Output = Result<(), Self::Error>> + Send + '_ { ... }
}Expand description
Trait representing a part of an application lifecycle.
Implementors define async hooks for startup, running, and shutdown phases.
All hooks should return immediately if cancelled via the provided CancellationToken.
Hooks are run in parallel for all parts.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn before_startup(
&mut self,
cancellation_token: CancellationToken,
) -> impl Future<Output = Result<(), Self::Error>> + Send + '_
fn before_startup( &mut self, cancellation_token: CancellationToken, ) -> impl Future<Output = Result<(), Self::Error>> + Send + '_
Sourcefn before_shutdown(
&mut self,
cancellation_token: CancellationToken,
) -> impl Future<Output = Result<(), Self::Error>> + Send + '_
fn before_shutdown( &mut self, cancellation_token: CancellationToken, ) -> impl Future<Output = Result<(), Self::Error>> + Send + '_
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.