Skip to main content

Screen

Trait Screen 

Source
pub trait Screen {
    type Error: From<Error>;

    // Required methods
    fn render(&self, frame: &mut Frame<'_>);
    fn handle_key(
        &mut self,
        key: KeyEvent,
        tui: &mut Tui,
    ) -> Result<Flow, Self::Error>;

    // Provided method
    fn tick(&mut self) { ... }
}
Expand description

A full-screen UI that run can drive.

render is &self so it can be reused as the background of a modal while the handler holds &mut Tui. The associated Error keeps this kit free of any concrete error crate; it only needs to absorb I/O errors.

Required Associated Types§

Source

type Error: From<Error>

The host’s error type; only needs to absorb I/O errors.

Required Methods§

Source

fn render(&self, frame: &mut Frame<'_>)

Draws the screen into frame.

Source

fn handle_key( &mut self, key: KeyEvent, tui: &mut Tui, ) -> Result<Flow, Self::Error>

Handles a key press, returning whether to keep running or quit.

§Errors

Returns the host’s error if handling the key fails.

Provided Methods§

Source

fn tick(&mut self)

Called on each idle tick (no input within TICK); use it to advance animations. Default: do nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§