pub struct Pipeline { /* private fields */ }Expand description
A composable pipeline that passes a string through a sequence of named stages.
§Guarantees
- Stages execute in insertion order
- First stage failure short-circuits remaining stages (unless an error handler is set)
- Non-panicking
Implementations§
Source§impl Pipeline
impl Pipeline
Sourcepub fn with_error_handler(
self,
handler: impl Fn(&str, &str) -> String + Send + Sync + 'static,
) -> Self
pub fn with_error_handler( self, handler: impl Fn(&str, &str) -> String + Send + Sync + 'static, ) -> Self
Attach a recovery callback for stage failures.
When a stage fails, handler(stage_name, error_message) is called.
The returned string becomes the input to the next stage.
If no handler is set, stage failures propagate as errors.
Sourcepub fn add_stage(
self,
name: impl Into<String>,
handler: impl Fn(String) -> Result<String, AgentRuntimeError> + Send + Sync + 'static,
) -> Self
pub fn add_stage( self, name: impl Into<String>, handler: impl Fn(String) -> Result<String, AgentRuntimeError> + Send + Sync + 'static, ) -> Self
Append a stage to the pipeline.
Sourcepub fn run(&self, input: String) -> Result<String, AgentRuntimeError>
pub fn run(&self, input: String) -> Result<String, AgentRuntimeError>
Execute the pipeline, passing input through each stage in order.
Sourcepub fn execute_timed(
&self,
input: String,
) -> Result<PipelineResult, AgentRuntimeError>
pub fn execute_timed( &self, input: String, ) -> Result<PipelineResult, AgentRuntimeError>
Execute the pipeline with per-stage timing.
Sourcepub fn stage_count(&self) -> usize
pub fn stage_count(&self) -> usize
Return the number of stages in the pipeline.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pipeline
impl !RefUnwindSafe for Pipeline
impl Send for Pipeline
impl Sync for Pipeline
impl Unpin for Pipeline
impl UnsafeUnpin for Pipeline
impl !UnwindSafe for Pipeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more