Struct CommandMachine

Source
pub struct CommandMachine<C: Command> { /* private fields */ }
Expand description

Track mapped commands and handle their execution.

Implementations§

Source§

impl<C: Command> CommandMachine<C>

Source

pub fn new() -> Self

Create a new instance.

Source

pub fn add_command(&mut self, cmd: C)

Map a command under its names.

Source

pub fn complete_name(&self, prefix: &str) -> Vec<String>

Generate a list of completion candidates for command names.

Source

pub fn complete_aliases(&self, prefix: &str) -> Vec<String>

Generate a list of completion candidates for command aliases.

Source

pub fn get(&self, name: &str) -> Result<&C, CommandError>

Get the previously executed command.

Source

pub fn get_last_command(&self) -> String

Get the previously executed command.

Source

pub fn input_cmd<T: Into<String>>( &mut self, input: T, ctx: C::Context, ) -> Result<Vec<(C::Action, C::Context)>, CommandError>

Parse and execute a command string.

Trait Implementations§

Source§

impl<C, I> Commandable<C, I> for CommandMachine<C>
where C: Command<Action = Action<I>, Context = EditContext>, I: ApplicationInfo,

Source§

fn command( &mut self, action: &CommandAction, ctx: &C::Context, rstore: &mut RegisterStore, ) -> UIResult<Vec<(Action<I>, C::Context)>, I>

Execute a command action.
Source§

impl<C: Debug + Command> Debug for CommandMachine<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for CommandMachine<C>

§

impl<C> RefUnwindSafe for CommandMachine<C>
where C: RefUnwindSafe,

§

impl<C> Send for CommandMachine<C>
where C: Send,

§

impl<C> Sync for CommandMachine<C>
where C: Sync,

§

impl<C> Unpin for CommandMachine<C>

§

impl<C> UnwindSafe for CommandMachine<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> Any for T
where T: Any,