Trait InputOutput

Source
pub trait InputOutput {
    // Required methods
    fn print(&self, text: &str) -> Result<(), Error>;
    fn println(&self, text: &str) -> Result<(), Error>;
    fn flush(&self) -> Result<(), Error>;
    fn read_line(&self) -> Result<String, Error>;
    fn read_line_with_timeout(&self, timeout: Duration) -> Result<String, Error>;
}
Expand description

Trait abstraction for input/output operations to enable mocking

Required Methods§

Source

fn print(&self, text: &str) -> Result<(), Error>

Print text to output

§Errors

Returns an error if the output operation fails

Source

fn println(&self, text: &str) -> Result<(), Error>

Print text to output with newline

§Errors

Returns an error if the output operation fails

Source

fn flush(&self) -> Result<(), Error>

Flush output buffer

§Errors

Returns an error if the flush operation fails

Source

fn read_line(&self) -> Result<String, Error>

Read a line of input from user

§Errors

Returns an error if the input operation fails

Source

fn read_line_with_timeout(&self, timeout: Duration) -> Result<String, Error>

Read a line of input from user with timeout

§Errors

Returns an error if the input operation fails or times out

Implementors§