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§
Sourcefn on_before(&self, event: HookEvent, callback: HookCallback)
fn on_before(&self, event: HookEvent, callback: HookCallback)
注册前置钩子
Sourcefn on_after(&self, event: HookEvent, callback: HookCallback)
fn on_after(&self, event: HookEvent, callback: HookCallback)
注册后置钩子
Sourcefn 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 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,
触发钩子
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".