Struct repl_rs::Repl

source ·
pub struct Repl<Context, E: Display> { /* private fields */ }
Expand description

Main REPL struct

Implementations§

source§

impl<Context, E> Repl<Context, E>where E: Display + From<Error>,

source

pub fn new(context: Context) -> Self

Create a new Repl with the given context’s initial value.

source

pub fn with_name(self, name: &str) -> Self

Give your Repl a name. This is used in the help summary for the Repl.

source

pub fn with_version(self, version: &str) -> Self

Give your Repl a version. This is used in the help summary for the Repl.

source

pub fn with_description(self, description: &str) -> Self

Give your Repl a description. This is used in the help summary for the Repl.

source

pub fn with_prompt(self, prompt: &'static dyn Display) -> Self

Give your Repl a custom prompt. The default prompt is the Repl name, followed by a >, all in green, followed by a space.

source

pub fn with_help_viewer<V: 'static + HelpViewer>(self, help_viewer: V) -> Self

Pass in a custom help viewer

source

pub fn with_error_handler( self, handler: fn(error: E, repl: &Repl<Context, E>) -> Result<()> ) -> Self

Pass in a custom error handler. This is really only for testing - the default error handler simply prints the error to stderr and then returns

source

pub fn use_completion(self, value: bool) -> Self

Set whether to use command completion when tab is hit. Defaults to false.

source

pub fn add_command(self, command: Command<Context, E>) -> Self

Add a command to your REPL

source

pub fn run(&mut self) -> Result<()>

Auto Trait Implementations§

§

impl<Context, E> !RefUnwindSafe for Repl<Context, E>

§

impl<Context, E> !Send for Repl<Context, E>

§

impl<Context, E> !Sync for Repl<Context, E>

§

impl<Context, E> Unpin for Repl<Context, E>where Context: Unpin,

§

impl<Context, E> !UnwindSafe for Repl<Context, E>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.