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
orAsyncHandler
, 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
Trait Implementations
Auto Trait Implementations
impl<T, M, H> RefUnwindSafe for Shell<T, M, H> where
H: RefUnwindSafe,
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M, H> UnwindSafe for Shell<T, M, H> where
H: UnwindSafe,
M: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more