Trait modalkit::commands::Command

source ·
pub trait Command: Clone {
    type Parsed: ParsedCommand;
    type Action;
    type Context;
    type CommandContext: From<Self::Context>;

    // Required methods
    fn name(&self) -> String;
    fn aliases(&self) -> Vec<String>;
    fn exec(
        &self,
        cmd: Self::Parsed,
        ctx: &mut Self::CommandContext
    ) -> CommandResult<Self>;
}
Expand description

Trait for mapped commands.

Required Associated Types§

source

type Parsed: ParsedCommand

Result of parsing a command string.

source

type Action

Result of running a command.

source

type Context

Context provided with each command string.

source

type CommandContext: From<Self::Context>

Context to be passed to Command::exec.

Required Methods§

source

fn name(&self) -> String

The primary name to map this command under.

source

fn aliases(&self) -> Vec<String>

Additional names to map this command under.

source

fn exec( &self, cmd: Self::Parsed, ctx: &mut Self::CommandContext ) -> CommandResult<Self>

Execute this command.

Object Safety§

This trait is not object safe.

Implementors§