Skip to main content

InferenceHook

Trait InferenceHook 

Source
pub trait InferenceHook: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 PluginContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A focused hook trait for code that only needs to intercept inference before or after it happens, without needing the full StagePlugin position system.

Hooks are registered via PluginRegistry::register_pre_hook and PluginRegistry::register_post_hook. They are called with a rich PluginContext rather than the generic PluginInput.

Required Methods§

Source

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

Human-readable name for logging/metrics.

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 PluginContext, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called with the full inference context. Return Ok(()) to continue; return Err(msg) to abort the pipeline and return the error to the caller.

§Errors

Return an Err string to signal that the hook detected an unrecoverable problem (e.g., budget exceeded, PII detected).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§