Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn phases(&self) -> Vec<MiddlewarePhase>;
    fn handle<'a>(
        &'a self,
        ctx: &'a MiddlewareContext,
    ) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'a>>;
}
Expand description

Middleware trait — implement this to add behavior to the agent pipeline.

Required Methods§

Source

fn name(&self) -> &str

Human-readable name of this middleware, used for logging and lookup.

Source

fn phases(&self) -> Vec<MiddlewarePhase>

Phases at which this middleware wishes to be invoked.

Source

fn handle<'a>( &'a self, ctx: &'a MiddlewareContext, ) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'a>>

Inspect the context for the current phase and return a result.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§