traverse_with_progress

Function traverse_with_progress 

Source
pub fn traverse_with_progress<T, U, Env, F, Eff>(
    items: Vec<T>,
    stage_name: &str,
    f: F,
) -> impl Effect<Output = Vec<U>, Error = AnalysisError, Env = Env>
where T: Send + 'static, U: Send + 'static, Env: HasProgress + Clone + Send + Sync + 'static, F: Fn(T) -> Eff + Send + Sync + 'static, Eff: Effect<Output = U, Error = AnalysisError, Env = Env> + Send,
Expand description

Traverse items with automatic progress reporting.

This combinator processes items sequentially, reporting progress after each item completes. The stage is automatically started at the beginning and completed at the end.

§Arguments

  • items - The items to process
  • stage_name - The name of the stage for progress reporting
  • f - A function that creates an effect for each item

§Returns

An effect that produces a vector of results.

§Example

let files = vec!["a.rs", "b.rs", "c.rs"];
let effect = traverse_with_progress(
    files,
    "File Analysis",
    |path| analyze_file_effect(path)
);

// Progress: File Analysis 0/3, 1/3, 2/3, 3/3
let results = effect.run(&env).await?;

§Error Handling

If any item fails, the traversal stops and returns the error. The stage is still completed for proper cleanup.