Trait LifecycleHook

Source
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§

Source

fn name(&self) -> &'static str

Hook name for identification

Provided Methods§

Source

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

Source

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

Source

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,

Called before application shutdown

Source

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,

Called after application shutdown

Implementors§