Trait vmm_sys_util::terminal::Terminal[][src]

pub unsafe trait Terminal {
    fn tty_fd(&self) -> RawFd;

    fn set_canon_mode(&self) -> Result<()> { ... }
fn set_raw_mode(&self) -> Result<()> { ... }
fn set_non_block(&self, non_block: bool) -> Result<()> { ... }
fn read_raw(&self, out: &mut [u8]) -> Result<usize> { ... } }

Trait for file descriptors that are TTYs, according to isatty.

This is marked unsafe because the implementation must ensure that the returned RawFd is a valid fd and that the lifetime of the returned fd is at least that of the trait object.

Required methods

fn tty_fd(&self) -> RawFd[src]

Get the file descriptor of the TTY.

Loading content...

Provided methods

fn set_canon_mode(&self) -> Result<()>[src]

Set this terminal to canonical mode (ICANON | ECHO | ISIG).

Enable canonical mode with ISIG that generates signal when receiving any of the characters INTR, QUIT, SUSP, or DSUSP, and with ECHO that echo the input characters. Refer to termios.

fn set_raw_mode(&self) -> Result<()>[src]

Set this terminal to raw mode.

Unset the canonical mode with (!(ICANON | ECHO | ISIG)) which means input is available character by character, echoing is disabled and special signal of receiving characters INTR, QUIT, SUSP, or DSUSP is disabled.

fn set_non_block(&self, non_block: bool) -> Result<()>[src]

Set this terminal to non-blocking mode.

If non_block is true, then read_raw will not block. If non_block is false, then read_raw may block if there is nothing to read.

fn read_raw(&self, out: &mut [u8]) -> Result<usize>[src]

Read from a Terminal.

Read up to out.len() bytes from this terminal without any buffering. This may block, depending on if non-blocking was enabled with set_non_block or if there are any bytes to read. If there is at least one byte that is readable, this will not block.

Examples

extern crate vmm_sys_util;
use vmm_sys_util::terminal::Terminal;

let stdin_handle = io::stdin();
let stdin = stdin_handle.lock();
assert!(stdin.set_non_block(true).is_ok());

let mut out = [0u8; 0];
assert_eq!(stdin.read_raw(&mut out[..]).unwrap(), 0);
Loading content...

Implementations on Foreign Types

impl<'a> Terminal for StdinLock<'a>[src]

Loading content...

Implementors

Loading content...