Skip to main content

HookSystemTrait

Trait HookSystemTrait 

Source
pub trait HookSystemTrait: Send + Sync {
    // Required methods
    fn on_before(&self, event: HookEvent, callback: HookCallback);
    fn on_after(&self, event: HookEvent, callback: HookCallback);
    fn trigger<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: &'life1 HookContext,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove(&self, event: HookEvent, is_before: bool);
    fn clear(&self);
    fn count(&self, event: HookEvent) -> (usize, usize);
}
Expand description

Hook 系统接口

Required Methods§

Source

fn on_before(&self, event: HookEvent, callback: HookCallback)

注册前置钩子

Source

fn on_after(&self, event: HookEvent, callback: HookCallback)

注册后置钩子

Source

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

触发钩子

Source

fn remove(&self, event: HookEvent, is_before: bool)

移除钩子

Source

fn clear(&self)

清除所有钩子

Source

fn count(&self, event: HookEvent) -> (usize, usize)

获取钩子数量

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§