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§
- Cancel
Progress ProgressSinkthat stops forwarding onceCancelorProgressSink::should_cancelfires.- Flag
Cancel - Shared flag for tests and embedders that flip cancellation mid-operation.
- Never
Cancel - A
Cancelthat never signals cancellation. The default for call sites that do not support interruption. - Null
Progress - A
ProgressSinkthat discards every update. The default for tests,grit-cli, and any call site that does not want progress output. - Overall
Estimate - A snapshot of overall progress.
- Overall
Estimator - Combines per-phase progress into one overall estimate.
- Phase
Rates - Typical throughput used to size phases that have not started yet.
- Received
Objects - How far a pack transfer has got, counted in objects rather than bytes.
- Watch
Progress ProgressSinkadapter that mirrorsProgressSink::should_cancelintowatch.
Enums§
- Progress
Phase - A coarse phase of a long-running Git operation.
- Progress
Unit - Unit for
ProgressSink::inc/ProgressSink::setduring a phase.
Traits§
- Cancel
- A cancellation signal checked by long-running library operations at loop boundaries. Implementations must be cheap to query.
- Progress
Sink - A sink for progress updates emitted by a library operation.
Functions§
- cancel_
watch_ arc - Shared
AtomicBoolfor cancellation visible across threads. - poll_
cancel - Returns
crate::error::Error::Cancelledwhencancelorprogressrequest stop. - poll_
cancel_ watch - Like
poll_cancel, but also records cancellation inwatchfor worker threads. - poll_
watch - Returns
crate::error::Error::Cancelledwhenwatchwas set.