Skip to main content

StdinReader

Trait StdinReader 

Source
pub trait StdinReader: Send + Sync {
    // Required methods
    fn is_terminal(&self) -> bool;
    fn read_to_string(&self) -> Result<String>;
}
Expand description

Abstraction over stdin reading.

This trait allows tests to mock stdin without actually piping data.

Required Methods§

Source

fn is_terminal(&self) -> bool

Check if stdin is a terminal (TTY).

Returns true if stdin is interactive, false if piped.

Source

fn read_to_string(&self) -> Result<String>

Read all content from stdin.

This should only be called if is_terminal() returns false.

Implementors§