PROGRESS & CANCELLATION FOR RUST LIBRARIES
Progress that follows
your functions.
One &dyn Pulse argument. Ordinary functions and results. Named stages when you need structure.
no_std + alloc · Your caller chooses what to observe
// Bind definitions to variables.
let (mut stages, [decode, resize]) =
Stages::define(pulse, [
PhaseSpec::new("decode", 4, Total::Unknown),
PhaseSpec::new("resize", 3, Total::Unknown),
]);
// Call your functions as usual.
let decode = stages.begin(decode);
let pixels = decode_image(input, &decode)
.finish_phase(decode)?;
let resize = stages.begin(resize);
let pixels = resize_image(pixels, &resize)
.finish_phase(resize)?;
stages.complete(Ok(pixels))? propagates an error.FOLLOW THE WORK
A small interface.
A visible lifecycle.
Step through snapshots recorded by the Rust tracker. These are illustrative events, not timings or benchmarks.
LOADING
Loading recorded events…
The guides below work without JavaScript.
Illustrative pace · actual tracker states
The estimate comes from Rust's ProgressSmoother; it changes only the display.
Progress counts work. Completion records its outcome.
Keep your return types
Return your own Result<T, E>. Implement AsStopReason on your error to distinguish cancellation from failure.
Compose ordinary calls
Stages can take different inputs and return different types. Forked handles use the same result handoff; your runtime schedules the work.
Let the caller choose
Pass NoPulse, a stop token adapter, or a tracker. Your library reports work. Its caller owns the display and final completion.
THREE CRATES, ONE DIRECTION
Add what you need.
Start with the core in your library. Tracking and diagnostics can stay in development dependencies until an application needs them.
[dependencies]
how-far = "0.1.0"A guide for your next step.
A function and its caller →
A complete example, dependency setup and the first result handoff.
02 / COMPOSEStages, errors and fork–join →
Bind definitions to variables and compose different operations.
03 / VERIFYTest what your library reports →
Check cancellation, inspect diagnostics and tune checkpoint cadence.