Struct shellfish::Shell[][src]

pub struct Shell<T, M: Display, H> {
    pub prompt: M,
    pub commands: HashMap<String, Command<T>>,
    pub state: T,
    pub handler: H,
    pub description: String,
}
Expand description

A shell represents a shell for editing commands in.

Here are the generics:

  • T: The state.
  • M: The prompt. Can be anything that can be printed.
  • H: The handler. Should implement either Handler or AsyncHandler, or no functionality is present.

Fields

prompt: M

The shell prompt.

It can be anything which implements Display and can therefore be printed (This allows for prompts that change with the state.)

commands: HashMap<String, Command<T>>

This is a list of commands for the shell. The hashmap key is the name of the command (ie "greet") and the value is a wrapper to the function it corresponds to (as well as help information.)

state: T

This is the state of the shell. This stores any values that you need to be persisted over multiple shell commands. For example it may be a simple counter or maybe a session ID.

handler: H

This is the handler for commands. See the Handler documentation for more.

description: String

This is the description of the shell as a whole. This is displayed when requesting help information.

Implementations

Creates a new shell

Creates a new shell with the given handler.

Starts running the shell

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.