pub trait ProgressReporter: Send + Sync {
// Required methods
fn set_message(&self, message: &str);
fn set_progress(&self, current: u64, total: u64);
fn finish_success(&self, message: &str);
fn finish_error(&self, message: &str);
// Provided method
fn inc(&self, delta: u64) { ... }
}Expand description
Trait for reporting progress during long-running operations.
This trait decouples the storage layer from the UI layer, allowing
operations like S3 uploads to report progress without depending on
typub-ui.
§Implementations
NullReporter- Discards all progress reports (default)FnReporter- Wraps a closure for simple progress reportingtypub-uiprovidesIndicatifReporterwith progress bars (Phase 4)
§Example
use typub_log::{ProgressReporter, NullReporter};
fn upload_with_progress(reporter: &dyn ProgressReporter) {
reporter.set_message("Uploading assets...");
for i in 0..10 {
// ... upload logic ...
reporter.set_progress(i + 1, 10);
}
reporter.finish_success("Upload complete");
}
// Use null reporter when no UI is available
upload_with_progress(&NullReporter);Required Methods§
Sourcefn set_message(&self, message: &str)
fn set_message(&self, message: &str)
Set the current progress message.
Sourcefn set_progress(&self, current: u64, total: u64)
fn set_progress(&self, current: u64, total: u64)
Set progress as (current, total).
For indeterminate progress, call with (0, 0).
Sourcefn finish_success(&self, message: &str)
fn finish_success(&self, message: &str)
Mark the operation as successfully completed.
Sourcefn finish_error(&self, message: &str)
fn finish_error(&self, message: &str)
Mark the operation as failed.
Provided Methods§
Implementations on Foreign Types§
Source§impl ProgressReporter for ()
Unit type implements ProgressReporter as a null reporter.
impl ProgressReporter for ()
Unit type implements ProgressReporter as a null reporter.
This allows passing &() when no progress reporting is needed.