Struct calypso_repl::Repl

source ·
pub struct Repl<Ctx> {
    pub(crate) eval: Eval<Ctx>,
    pub(crate) cmds: Vec<Arc<Command<Ctx>>>,
    pub(crate) cache: HashMap<String, Arc<Command<Ctx>>>,
    pub(crate) editor: Editor<()>,
    pub(crate) ctx: Ctx,
    pub(crate) prefix: String,
    pub(crate) cmd_regex: Regex,
}
Expand description

A struct for doing REPL-like activities. This does not necessarily need to fit the exact definition of REPL (Read, Eval, Print, Loop).

The Ctx type parameter can be any type of REPL-global context, e.g. a parser context or perhaps an environment structure.

The command help, with aliases ['h', '?'] is reserved.

Fields§

§eval: Eval<Ctx>

A closure that evaluates the input and returns something implementing Display

§cmds: Vec<Arc<Command<Ctx>>>

Meta-command definitions. This is a Vec as you may want to dynamically initialize commands.

§cache: HashMap<String, Arc<Command<Ctx>>>

A HashMap containing references to the commands. This is cached to allow faster command execution.

§editor: Editor<()>

The Rustyline context

§ctx: Ctx

The context

§prefix: String

Prefix for commands. Default: :

§cmd_regex: Regex

Regex for commands

Implementations§

Extend the commands vector

Add a command

Run the REPL.

Errors

The only errors currently returned by this function are errors from rustyline.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.