Skip to main content

Terminal

Trait Terminal 

Source
pub trait Terminal {
    // Required methods
    fn write(&mut self, bytes: &[u8]) -> Result<()>;
    fn read(
        &mut self,
        buf: &mut [u8],
        timeout: Option<Duration>,
    ) -> Result<Option<usize>>;

    // Provided methods
    fn restore(&mut self) -> Result<()> { ... }
    fn modes(&mut self, _paste: bool, _kitty: bool) { ... }
}
Expand description

A byte stream to a terminal with a timed read.

Required Methods§

Source

fn write(&mut self, bytes: &[u8]) -> Result<()>

Writes all of bytes and flushes.

§Errors

When the output fails.

Source

fn read( &mut self, buf: &mut [u8], timeout: Option<Duration>, ) -> Result<Option<usize>>

Reads available input into buf, waiting at most timeout (None waits for input). Ok(None) means the wait timed out; Ok(Some(0)) that the input is closed.

§Errors

When the input fails.

Provided Methods§

Source

fn restore(&mut self) -> Result<()>

Puts the terminal back as it was (leaves raw mode). Called once, when the session closes or fails to connect.

§Errors

When the terminal can’t be restored.

Source

fn modes(&mut self, _paste: bool, _kitty: bool)

Notes which input modes the session enabled, so a process killed by a signal can still undo them.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Terminal for Tty

Available on Unix or Windows only.