pub trait AnyHookHandler: Send + Sync {
// Required methods
fn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
payload: &'life1 dyn PluginPayload,
extensions: &'life2 Extensions,
ctx: &'life3 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send + Sync>, Box<PluginError>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn hook_type_name(&self) -> &'static str;
}Expand description
Type-erased interface for calling a hook handler.
The executor uses this to dispatch hooks without knowing the
concrete handler trait at compile time. Each handler wraps a
plugin that implements a specific handler trait (e.g.,
CmfHookHandler) and translates between type-erased payloads
and the typed handler method.
The executor dispatches through this trait for all five phases. The handler receives a borrowed payload — the framework retains ownership. Plugins clone only when modifying.
invoke is async so that plugins can perform I/O (HTTP calls,
Redis, vault lookups) without blocking the tokio runtime, and
so that tokio::time::timeout can actually observe and cancel
long-running handlers.
Required Methods§
Sourcefn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
payload: &'life1 dyn PluginPayload,
extensions: &'life2 Extensions,
ctx: &'life3 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send + Sync>, Box<PluginError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
payload: &'life1 dyn PluginPayload,
extensions: &'life2 Extensions,
ctx: &'life3 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send + Sync>, Box<PluginError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Call the handler with a borrowed payload.
Returns an ErasedResultFields (see executor module) wrapped
as Box<dyn Any>. If the handler modified the payload, the
modified copy is in ErasedResultFields.modified_payload.
Sourcefn hook_type_name(&self) -> &'static str
fn hook_type_name(&self) -> &'static str
The hook type name this handler was registered for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".