pub trait TerminalSetup {
type B: Backend;
// Required methods
fn enable(&mut self) -> Result<()>;
fn create_terminal(&mut self) -> Result<Terminal<Self::B>>;
fn disable(&mut self);
fn print_done(&self);
}Expand description
Abstracts terminal setup/teardown so a UI’s generic core can be tested with
a ratatui::backend::TestBackend and no-op TTY operations. The real
crossterm implementation (CrosstermSetup) lives in the binary, since it
can only be exercised against a real terminal.
Required Associated Types§
Required Methods§
Sourcefn create_terminal(&mut self) -> Result<Terminal<Self::B>>
fn create_terminal(&mut self) -> Result<Terminal<Self::B>>
Build the terminal the UI draws into. Called after Self::enable.
Sourcefn disable(&mut self)
fn disable(&mut self)
Hand the terminal back. Must tolerate being called twice: the panic hook calls it too, and a panic during teardown would otherwise leave a terminal in raw mode.
Sourcefn print_done(&self)
fn print_done(&self)
Print whatever should remain on screen after the UI exits.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".