pub trait ProgressSink:
Send
+ Sync
+ 'static {
// Required methods
fn report(&self, stage: &str, current: usize, total: usize);
fn start_stage(&self, name: &str);
fn complete_stage(&self, name: &str);
fn warn(&self, message: &str);
fn child(&self, prefix: &str) -> Arc<dyn ProgressSink>;
}Expand description
Progress sink abstraction - receives progress updates.
Implementations handle progress visualization (TUI, CLI, logging). All methods should be cheap - expensive work should be deferred.
§Implementation Requirements
- All methods must be non-blocking
- Methods may be called from multiple threads concurrently
- Methods should not panic on invalid input (e.g., current > total)
- The
childmethod should return a sink that prefixes stage names
§Method Costs
| Method | Expected Cost |
|---|---|
report | O(1), minimal allocation |
start_stage | O(1), may log or update UI |
complete_stage | O(1), may log or update UI |
warn | O(1), may log |
child | O(1), creates new Arc |
Required Methods§
Sourcefn start_stage(&self, name: &str)
fn start_stage(&self, name: &str)
Report a sub-stage starting.
This is called at the beginning of a stage. Implementations may:
- Display a message
- Start a timer
- Initialize UI elements
§Arguments
name- The name of the stage being started
Sourcefn complete_stage(&self, name: &str)
fn complete_stage(&self, name: &str)
Report a stage completing.
This is called when a stage finishes (successfully or with error).
Implementations should clean up any resources started in start_stage.
§Arguments
name- The name of the stage that completed
Sourcefn warn(&self, message: &str)
fn warn(&self, message: &str)
Report a warning without interrupting progress.
Warnings should be displayed in a way that doesn’t disrupt the progress display. For example:
- Log to a separate area in TUI
- Print to stderr in CLI mode
- Collect for later display
§Arguments
message- The warning message