Skip to main content

LiveConsole

Struct LiveConsole 

Source
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

Source

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.

Source

pub fn hidden(config: LiveConfig) -> Self

Create a console whose output is discarded — for tests and non-terminal runs where the live area must not render.

Source

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.

Source

pub fn set_header(&self, text: impl Into<String>)

Set the status line shown above the tiles.

Source

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.

Source

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.

Source

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.

Source

pub fn finish_with_replay( &mut self, id: &str, verdict: impl AsRef<str>, ) -> Result<()>

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. A finish for an unknown id prints only the verdict. Returns any I/O error from the flush or verdict write.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.