Skip to main content

InputBackend

Trait InputBackend 

Source
pub trait InputBackend: Send {
    // Required method
    fn read_line(
        &mut self,
        shell: &ShellRef<impl ShellExtensions>,
        prompt: InteractivePrompt,
    ) -> Result<ReadResult, ShellError>;

    // Provided methods
    fn get_read_buffer(&self) -> Option<(String, usize)> { ... }
    fn set_read_buffer(&mut self, _buffer: String, _cursor: usize) { ... }
}
Expand description

Represents an input backend for reading lines of input.

Required Methods§

Source

fn read_line( &mut self, shell: &ShellRef<impl ShellExtensions>, prompt: InteractivePrompt, ) -> Result<ReadResult, ShellError>

Reads a line of input, using the given prompt.

§Arguments
  • shell - The shell instance for which input is being read.
  • prompt - The prompt to display to the user.

Provided Methods§

Source

fn get_read_buffer(&self) -> Option<(String, usize)>

Returns the current contents of the read buffer and the current cursor position within the buffer; None is returned if the read buffer is empty or cannot be read by this implementation.

Source

fn set_read_buffer(&mut self, _buffer: String, _cursor: usize)

Updates the read buffer with the given string and cursor. Considered a no-op if the implementation does not support updating read buffers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§