Skip to main content

Hook

Trait Hook 

Source
pub trait Hook: Send + Sync {
    // Required methods
    fn events(&self) -> &[HookEvent];
    fn on_event<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 HookContext,
    ) -> Pin<Box<dyn Future<Output = HookAction> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn name(&self) -> &str { ... }
}

Required Methods§

Source

fn events(&self) -> &[HookEvent]

Which events this hook handles.

Source

fn on_event<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 HookContext, ) -> Pin<Box<dyn Future<Output = HookAction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when a matching event fires. Returns an action to control flow.

Provided Methods§

Source

fn name(&self) -> &str

Optional name for logging/debugging.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§