pub trait ProgressSink {
// Provided methods
fn start(&mut self, phase: ProgressPhase, total: Option<u64>) { ... }
fn start_with_unit(
&mut self,
phase: ProgressPhase,
unit: ProgressUnit,
total: Option<u64>,
) { ... }
fn inc(&mut self, units: u64) { ... }
fn set(&mut self, current: u64) { ... }
fn finish(&mut self) { ... }
fn should_cancel(&self) -> bool { ... }
}Expand description
A sink for progress updates emitted by a library operation.
Every method has a no-op default, so a sink implements only what it needs. The library calls these from the caller’s thread at coarse intervals; it never decides whether output is a tty, what colour to use, or how often to redraw — that is the CLI’s responsibility.
Provided Methods§
Sourcefn start(&mut self, phase: ProgressPhase, total: Option<u64>)
fn start(&mut self, phase: ProgressPhase, total: Option<u64>)
Begin a new progress phase, optionally with a known total count of
ProgressPhase::default_unit units for that phase.
total may be None when the operation cannot estimate the final
count (common for network receives).
Sourcefn start_with_unit(
&mut self,
phase: ProgressPhase,
unit: ProgressUnit,
total: Option<u64>,
)
fn start_with_unit( &mut self, phase: ProgressPhase, unit: ProgressUnit, total: Option<u64>, )
Begin a phase with an explicit count unit (for example ProgressUnit::Bytes
when streaming a pack whose size is known in bytes).
Defaults to Self::start; override when the sink renders counts differently
per ProgressUnit.
Sourcefn set(&mut self, current: u64)
fn set(&mut self, current: u64)
Set the absolute progress of the current phase to current units.
Sourcefn should_cancel(&self) -> bool
fn should_cancel(&self) -> bool
When true, the operation should stop at the next poll_cancel check.
CLI progress sinks may set this when the user interrupts (Ctrl+C). Most
call sites rely on a separate Cancel argument instead; either signal
produces crate::error::Error::Cancelled.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: ProgressSink + ?Sized> ProgressSink for &mut T
Forwarding impl so a &mut P can be threaded into sub-operations that also
take impl ProgressSink without re-borrowing gymnastics at every call site.
impl<T: ProgressSink + ?Sized> ProgressSink for &mut T
Forwarding impl so a &mut P can be threaded into sub-operations that also
take impl ProgressSink without re-borrowing gymnastics at every call site.