Skip to main content

Module progress_render

Module progress_render 

Source
Expand description

Terminal renderer for the generic Progress substrate.

This is the only place that turns a ProgressSnapshot into bytes on a terminal. Domain crates drive a Progress handle; the CLI installs a TerminalSink via the JSON-guarded factory (progress_for) so progress is written to stderr and never leaks into result-only stdout (#550).

§Throttling lives here

Progress::inc calls render on every active tick; the sink decides whether to actually repaint. We coalesce to at most one redraw per COMMIT_TICK_INTERVAL completed units, but always repaint on a phase change so stage transitions show immediately. This mirrors the cadence of the bespoke import progress line this sink replaces.

Structs§

TerminalSink
A Sink that paints a single, self-overwriting progress line.

Constants§

COMMIT_TICK_INTERVAL
Redraw the live line at most once per this many completed units, so a large operation doesn’t spend its time flushing the terminal. Matches the historic import cadence.

Functions§

clear_line
Clear an active TTY progress line before rendering command output.
finish_line
Paint a terminal “done” line for a finished Progress, clearing the live line first on a TTY. No-op for a null (inactive) handle. Used by consumers that want an explicit completion marker (e.g. import’s [done] line).
format_transfer_bytes
progress_for
Build a Progress handle for a command, applying the single JSON guard (#550) exactly once at construction: JSON output → a null handle that renders nothing; otherwise → a TerminalSink. The guard is never checked again per update.