pub struct Progress { /* private fields */ }Expand description
Reports progress for a batch of N items as an in-place bar (brew/docker/
npm style) when stderr is a terminal, or periodic plain-text lines when
it isn’t (piped to a file, CI log), so a long run never looks hung in a
log file, without per-item spam either way. silent suppresses the bar
and periodic lines entirely, but NOT error output (see println) or the
caller’s own decision about whether to print a final summary.
Does not track elapsed time itself: callers that need it (e.g.
faces.rs, whose summary spans both detection and clustering, not just
the Progress-tracked detection phase) should use their own Instant
spanning whatever the summary needs to cover.
Safe to share across threads: every method takes &self, so a single
Progress value can be ticked concurrently from multiple rayon
worker threads (e.g. from inside a .par_iter() closure) with no
external Arc/Mutex wrapping needed at the call site.
Implementations§
Source§impl Progress
impl Progress
Sourcepub fn new(total: u64, silent: bool) -> Self
pub fn new(total: u64, silent: bool) -> Self
Creates a progress reporter for total items. When stderr is a TTY,
renders an in-place bar. When it isn’t, falls back to one plain-text
line every LOG_INTERVAL items. silent suppresses both.
Sourcepub fn tick(&self)
pub fn tick(&self)
Advance by one item. Safe to call concurrently from multiple threads
(e.g. from inside a rayon .par_iter() closure) via a shared
&Progress, no external synchronization needed.
Sourcepub fn tick_by(&self, n: u64)
pub fn tick_by(&self, n: u64)
Advance by n items at once (for callers that complete work in
batches rather than one item at a time, e.g. videre embed’s
chunked pipeline). n must not exceed the number of items remaining
toward total (mirrors the same implicit contract tick() already
has: callers are responsible for not calling it more times, or with
a larger cumulative n, than total allows). Safe to call
concurrently from multiple threads, same as tick().
Sourcepub fn println(&self, msg: &str)
pub fn println(&self, msg: &str)
Print a line that survives an active progress bar without corrupting
its rendering. Always prints, regardless of silent, matches the
existing unconditional behavior of per-image error messages
(detect failed ..., embed_batch failed ..., write failed ...),
which must stay visible even under –silent since they indicate data
loss, not routine progress.