NarjuIo

Trait NarjuIo 

Source
pub trait NarjuIo {
    // Required methods
    fn read_line(&mut self, prompt: &str) -> Result<Option<String>, NarjuError>;
    fn print(&mut self, s: &str) -> Result<(), NarjuError>;
}
Expand description

Input and output as the evaluator sees them.

One boxed instance lives in crate::eval::EvalCtx for the life of a session. The trait is deliberately minimal: a line in, a line out. Prompts, colour, history, and completion are implementation details behind it.

Required Methods§

Source

fn read_line(&mut self, prompt: &str) -> Result<Option<String>, NarjuError>

Read one line of input, displaying prompt where that makes sense. Returns Ok(None) at end of input (EOF, Ctrl-D, or an exhausted script), which the floor’s read maps to nil.

Source

fn print(&mut self, s: &str) -> Result<(), NarjuError>

Write one line of output (no trailing newline in s; the implementation supplies it).

Implementors§