pub struct MiddlewareChain { /* private fields */ }Expand description
An ordered stack of middleware layers with onion semantics.
Cheap to clone (Arc layers); empty by default, and every consumer
(executor, tool executor, model wrapper) takes its original code path
when the chain is empty.
Implementations§
Source§impl MiddlewareChain
impl MiddlewareChain
Sourcepub fn layer<M: Middleware + 'static>(self, middleware: M) -> Self
pub fn layer<M: Middleware + 'static>(self, middleware: M) -> Self
Builder-style: append a layer (runs after the already-added layers on the way in, before them on the way out).
Sourcepub fn push(&mut self, middleware: Arc<dyn Middleware>) -> &mut Self
pub fn push(&mut self, middleware: Arc<dyn Middleware>) -> &mut Self
Append a pre-shared layer.
Sourcepub fn layers(&self) -> &[Arc<dyn Middleware>]
pub fn layers(&self) -> &[Arc<dyn Middleware>]
The layers, in registration order, as shared handles — the form
the executor’s layer_shared wiring takes them in when a resolved
composition attaches to a run (R0.11 wave 4).
Sourcepub async fn run_node<F, Fut>(
&self,
call: &mut NodeCall,
op: F,
) -> Result<NodeOutput>
pub async fn run_node<F, Fut>( &self, call: &mut NodeCall, op: F, ) -> Result<NodeOutput>
Run the onion around a node invocation: before-hooks inward, op,
after-hooks outward. See the module docs for the full contract.
Sourcepub async fn run_model<F, Fut>(
&self,
call: &mut ModelCall,
op: F,
) -> Result<ChatResponse>
pub async fn run_model<F, Fut>( &self, call: &mut ModelCall, op: F, ) -> Result<ChatResponse>
Run the onion around a model call. Same contract as
MiddlewareChain::run_node.
Sourcepub async fn run_tool<F, Fut>(
&self,
call: &mut ToolInvocation,
op: F,
) -> Result<Value>
pub async fn run_tool<F, Fut>( &self, call: &mut ToolInvocation, op: F, ) -> Result<Value>
Run the onion around a tool call. Same contract as
MiddlewareChain::run_node.