Skip to main content

Module progress

Module progress 

Source
Expand description

Progress reporting and cancellation across the library/CLI boundary.

Library operations never touch the terminal. Long-running work reports progress through a ProgressSink supplied by the caller and checks a Cancel signal at loop boundaries. The CLI provides a concrete sink that draws to stderr (gated on isatty) and decides colour, redraw rate, and whether a pager is attached; the library makes none of those decisions.

Sinks are invoked from the calling thread only, at coarse granularity (phase boundaries and periodic counts, not per-object spam). Totals passed to ProgressSink::start may be None when the operation cannot know the final count up front.

Tests, grit-cli, and any call site that does not want output use the no-op NullProgress / NeverCancel.

Library guide: progress

use grit_lib::progress::{NeverCancel, NullProgress};
let _sink = NullProgress;
let _cancel = NeverCancel;

Structs§

CancelProgress
ProgressSink that stops forwarding once Cancel or ProgressSink::should_cancel fires.
FlagCancel
Shared flag for tests and embedders that flip cancellation mid-operation.
NeverCancel
A Cancel that never signals cancellation. The default for call sites that do not support interruption.
NullProgress
A ProgressSink that discards every update. The default for tests, grit-cli, and any call site that does not want progress output.
OverallEstimate
A snapshot of overall progress.
OverallEstimator
Combines per-phase progress into one overall estimate.
PhaseRates
Typical throughput used to size phases that have not started yet.
ReceivedObjects
How far a pack transfer has got, counted in objects rather than bytes.
WatchProgress
ProgressSink adapter that mirrors ProgressSink::should_cancel into watch.

Enums§

ProgressPhase
A coarse phase of a long-running Git operation.
ProgressUnit
Unit for ProgressSink::inc / ProgressSink::set during a phase.

Traits§

Cancel
A cancellation signal checked by long-running library operations at loop boundaries. Implementations must be cheap to query.
ProgressSink
A sink for progress updates emitted by a library operation.

Functions§

cancel_watch_arc
Shared AtomicBool for cancellation visible across threads.
poll_cancel
Returns crate::error::Error::Cancelled when cancel or progress request stop.
poll_cancel_watch
Like poll_cancel, but also records cancellation in watch for worker threads.
poll_watch
Returns crate::error::Error::Cancelled when watch was set.