pub struct Progress(/* private fields */);Expand description
A cheap-to-clone progress handle.
Cloning bumps an Arc refcount; all clones share the same counters and
sink, so a handle can be threaded through thread::scope closures or
stored alongside other shared state. Send + Sync.
Implementations§
Source§impl Progress
impl Progress
Sourcepub fn null() -> Self
pub fn null() -> Self
A handle that renders nothing. The hot path is a relaxed add plus a predicted-not-taken branch — see the module docs.
Sourcepub fn with_sink(sink: Box<dyn Sink>) -> Self
pub fn with_sink(sink: Box<dyn Sink>) -> Self
A handle backed by a real Sink. Every active inc will call
sink.render; the sink is responsible for throttling.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether this handle renders. false for Progress::null.
Sourcepub fn set_total(&self, total: usize)
pub fn set_total(&self, total: usize)
Set the total unit count. Cheap; does not trigger a render on its own.
Sourcepub fn set_phase(&self, label: impl Into<String>)
pub fn set_phase(&self, label: impl Into<String>)
Set the human phase label. Rare relative to inc; when active it also
triggers a render so the label change is painted immediately (a
terminal sink typically forces a repaint on phase change).
Sourcepub fn inc(&self, n: usize)
pub fn inc(&self, n: usize)
Advance the completed count by n and, if active, render.
Hot path: done.fetch_add(n, Relaxed) then one branch on the optional
sink. When inactive nothing else happens — no snapshot, no vtable call.
Sourcepub fn snapshot(&self) -> ProgressSnapshot
pub fn snapshot(&self) -> ProgressSnapshot
Take a current snapshot without rendering. Useful for a sink that wants to force a final repaint (e.g. a “done” line).