Skip to main content

ReplHandler

Trait ReplHandler 

Source
pub trait ReplHandler {
    // Required methods
    fn prompt(&self, is_continuation: bool) -> &str;
    fn is_complete(&self, code: &str) -> bool;
    fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>;

    // Provided methods
    fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>> { ... }
    fn get_indent(&self, _code: &str) -> usize { ... }
}
Expand description

Interface for language integration in the REPL.

Required Methods§

Source

fn prompt(&self, is_continuation: bool) -> &str

The prompt to display. is_continuation is true for multi-line input.

Source

fn is_complete(&self, code: &str) -> bool

Check if the input is complete (e.g., all brackets are closed). If it returns false, the REPL will enter multi-line input mode.

Source

fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>

Execute the given line of code.

Provided Methods§

Source

fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>

Get syntax highlighting for the given code.

Source

fn get_indent(&self, _code: &str) -> usize

Get the current indentation level for the next line in multi-line mode.

Implementors§