Skip to main content

Live

Struct Live 

Source
pub struct Live<W: Write> { /* private fields */ }
Expand description

An in-place updating display over a renderable. Mirrors rich.live.Live (manual-refresh subset). Output is written to a generic sink W, so it can target stdout or, in tests, a byte buffer.

Implementations§

Source§

impl<W: Write> Live<W>

Source

pub fn new(renderable: Box<dyn Renderable>, console: Console, writer: W) -> Self

Create a live display for renderable, rendering with console and writing control/output bytes to writer.

Source

pub fn start(&mut self)

Begin the live display: hide the cursor and draw the first frame.

Source

pub fn update(&mut self, renderable: Box<dyn Renderable>)

Swap in a new renderable and redraw in place.

Source

pub fn refresh(&mut self)

Redraw the current renderable in place (reposition over the last frame, then render).

Source

pub fn stop(&mut self)

Commit the final frame (with a trailing newline) and show the cursor.

Source

pub fn writer(&self) -> &W

The output sink (for inspecting captured bytes in tests).

Source

pub fn into_writer(self) -> W

Consume the display, returning its output sink.

Source§

impl<W: Write + Send + 'static> Live<W>

Source

pub fn spawn( renderable: Box<dyn Renderable + Send>, console: Console, writer: W, refresh_per_second: f64, ) -> AutoLive<W>

Start an auto-refreshing live display on a background thread: it draws the first frame, then redraws every 1/refresh_per_second seconds (and immediately on each AutoLive::update). Mirrors upstream’s auto_refresh/refresh_per_second. The renderable, console, and writer are moved into the thread, so all three must be Send.

Auto Trait Implementations§

§

impl<W> !Freeze for Live<W>

§

impl<W> !RefUnwindSafe for Live<W>

§

impl<W> !Send for Live<W>

§

impl<W> !Sync for Live<W>

§

impl<W> !UnwindSafe for Live<W>

§

impl<W> Unpin for Live<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Live<W>
where W: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.