pub trait LifecycleHook: Send + Sync {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn before_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn after_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn before_stop<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn after_stop<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Lifecycle hook trait for custom startup/shutdown behavior Uses boxed futures to maintain trait object compatibility
Required Methods§
Provided Methods§
Sourcefn before_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn before_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called before application startup
Sourcefn after_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn after_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called after successful startup