pub struct LiveConsole { /* private fields */ }Expand description
A live, multi-region terminal renderer.
Lifecycle per region: begin with a label,
feed raw bytes as they arrive,
then finish with a one-line verdict.
set_header updates a status line pinned above the tiles.
Implementations§
Source§impl LiveConsole
impl LiveConsole
Sourcepub fn to_stderr(config: LiveConfig) -> Self
pub fn to_stderr(config: LiveConfig) -> Self
Create a console that renders to stderr.
stderr keeps the live UI off stdout, leaving any machine-readable stream there uncorrupted.
Create a console whose output is discarded — for tests and non-terminal runs where the live area must not render.
Sourcepub fn content_cols(&self) -> usize
pub fn content_cols(&self) -> usize
The virtual terminal grid width: the tile width minus the content indent,
so a child fills the visible content area without being chopped.
Children feeding a tile should be sized to this; see LiveConfig::content_cols.
Sourcepub fn set_header(&self, text: impl Into<String>)
pub fn set_header(&self, text: impl Into<String>)
Set the status line shown above the tiles.
Sourcepub fn begin(&mut self, id: impl Into<String>, label: impl Into<String>)
pub fn begin(&mut self, id: impl Into<String>, label: impl Into<String>)
Start a new region tile labeled label, keyed by id.
A duplicate id discards the existing region first — dropping its tile and retained tail —
so a re-used key neither leaks a stale tile nor double-reports.
Sourcepub fn feed(&mut self, id: &str, bytes: &[u8])
pub fn feed(&mut self, id: &str, bytes: &[u8])
Feed raw output bytes to region id, updating its tile.
Rows evicted from the tile are dropped from the live view
but appended to the region’s bounded retention ring, so a later failure can replay recent context.
A feed for an unknown id is ignored, so late output after a finish cannot panic.
Sourcepub fn finish(&mut self, id: &str, verdict: impl AsRef<str>) -> Result<()>
pub fn finish(&mut self, id: &str, verdict: impl AsRef<str>) -> Result<()>
Finish region id, removing its tile and printing verdict as the only scrollback line —
the collapsed signal for a succeeding unit.
The region’s peeked output is discarded, not flushed:
on success the verdict (which the caller may enrich with a run summary) is the whole story.
A finish for an unknown id prints only the verdict. Returns any I/O error from the verdict write.
Sourcepub fn finish_with_replay(
&mut self,
id: &str,
verdict: impl AsRef<str>,
) -> Result<Vec<String>>
pub fn finish_with_replay( &mut self, id: &str, verdict: impl AsRef<str>, ) -> Result<Vec<String>>
Finish a failed region id, replaying its retained tail to scrollback as one contiguous,
label-prefixed block, then printing verdict.
The replay is the region’s retention ring (rows that scrolled off the tile, oldest first) followed by the rows still on screen
— a bounded, un-interleaved failure transcript. It is returned (un-prefixed, in order)
so the caller can also retain it for an end-of-run failure epilogue.
A finish for an unknown id prints only the verdict and returns an empty body.
Returns any I/O error from the flush or verdict write.
Sourcepub fn note(&self, line: impl AsRef<str>) -> Result<()>
pub fn note(&self, line: impl AsRef<str>) -> Result<()>
Print line to scrollback above the live area, without touching any tile.
For output that is not tied to a live region — a header banner, or a completed unit’s buffered block on the rare path where a unit is not live-tailed. Returns any I/O error from the write.
Sourcepub fn clear(&mut self) -> Result<()>
pub fn clear(&mut self) -> Result<()>
Drop every remaining region, then clear the live area and blank the header, leaving the console reusable.
Remaining regions are units that never finished; their peeked output is discarded (durable signal is emitted at finish time). Returns any I/O error from the terminal clear.