Trait Command

Source
pub trait Command: Sized {
    type Id: CommandId;
    type Path: CommandPath<Id = Self::Id>;

    // Required methods
    fn parse<I: IntoIterator<Item = S>, S: AsRef<str>>(
        iter: I,
    ) -> Result<Self, CommandParseError>;
    fn id(&self) -> Self::Id;
}
Expand description

A parsable, identifiable command or family of commands

Required Associated Types§

Source

type Id: CommandId

The type of the command ID

Source

type Path: CommandPath<Id = Self::Id>

The type of a valid command path starting at this command

Required Methods§

Source

fn parse<I: IntoIterator<Item = S>, S: AsRef<str>>( iter: I, ) -> Result<Self, CommandParseError>

Try to parse a sequence of arguments as a command

§Errors

Should return an error for syntax or command-not-found errors, or for any errors while parsing arguments.

Source

fn id(&self) -> Self::Id

Return an ID uniquely describing the base type of this command.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§