pub trait InteractiveShell: Send {
// Required methods
fn shell(&self) -> impl AsRef<Shell> + Send;
fn shell_mut(&mut self) -> impl AsMut<Shell> + Send;
fn read_line(
&mut self,
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) { ... }
fn run_interactively(
&mut self,
) -> impl Future<Output = Result<(), ShellError>> + Send { ... }
fn run_interactively_once(
&mut self,
) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send { ... }
fn execute_line(
&mut self,
read_result: String,
user_input: bool,
) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send { ... }
}Expand description
Represents a shell capable of taking commands from standard input.
Required Methods§
Sourcefn shell(&self) -> impl AsRef<Shell> + Send
fn shell(&self) -> impl AsRef<Shell> + Send
Returns an immutable reference to the inner shell object.
Sourcefn shell_mut(&mut self) -> impl AsMut<Shell> + Send
fn shell_mut(&mut self) -> impl AsMut<Shell> + Send
Returns a mutable reference to the inner shell object.
Sourcefn read_line(
&mut self,
prompt: InteractivePrompt,
) -> Result<ReadResult, ShellError>
fn read_line( &mut self, prompt: InteractivePrompt, ) -> Result<ReadResult, ShellError>
Reads a line of input, using the given prompt.
§Arguments
prompt- The prompt to display to the user.
Provided Methods§
Sourcefn get_read_buffer(&self) -> Option<(String, usize)>
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.
Sourcefn set_read_buffer(&mut self, _buffer: String, _cursor: usize)
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.
Sourcefn run_interactively(
&mut self,
) -> impl Future<Output = Result<(), ShellError>> + Send
fn run_interactively( &mut self, ) -> impl Future<Output = Result<(), ShellError>> + Send
Runs the interactive shell loop, reading commands from standard input and writing results to standard output and standard error. Continues until the shell normally exits or until a fatal error occurs.
Sourcefn run_interactively_once(
&mut self,
) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send
fn run_interactively_once( &mut self, ) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send
Runs the interactive shell loop once, reading a single command from standard input.
Sourcefn execute_line(
&mut self,
read_result: String,
user_input: bool,
) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send
fn execute_line( &mut self, read_result: String, user_input: bool, ) -> impl Future<Output = Result<InteractiveExecutionResult, ShellError>> + Send
Executes the given line of input.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.