pub struct CommandPlugin<I = (), O = ()> { /* private fields */ }Expand description
A command plugin. This registers:
- all commands registered to this plugin
- events with the supplied markers, which are
()by default - a dispatcher system to handle input events and dispatch commands.
Commands may be added with the CommandPlugin::register_command.
Argument types may be added with the CommandPlugin::register_argument.
Multiple instances of this plugin may be added to the same app,
but the generic parameters I and O must differ from any other existing ones.
The I parameter is used for the CommandInput event, and the O parameter is used for the CommandOutput event.
Other resources and registries used by this plugin are also parametrised with the I and O parameters.
Implementations§
Source§impl<I, O> CommandPlugin<I, O>
impl<I, O> CommandPlugin<I, O>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new command plugin with no commands and no parsers.
To add the default help command, call CommandPlugin::with_default_commands.
To add the default arguments, call CommandPlugin::with_default_args.
Sourcepub fn register_command(&self, command: CommandBuilder) -> &Self
pub fn register_command(&self, command: CommandBuilder) -> &Self
Register a command. The command handler will run on the Update schedule, as the dispatcher is registered to the same schedule.
Sourcepub fn register_argument<A: Argument>(&self) -> &Self
pub fn register_argument<A: Argument>(&self) -> &Self
Register an argument.
Sourcepub fn with_default_commands(&self) -> &Self
pub fn with_default_commands(&self) -> &Self
Register the “default” commands to this plugin.
The default commands are:
help: Provides a description and syntax for the command and its nodes
Sourcepub fn with_default_args(&self) -> &Self
pub fn with_default_args(&self) -> &Self
Register the “default” argument types to this plugin.
The default argument types are the ones in the builtins::args module.
Trait Implementations§
Source§impl<I, O> Default for CommandPlugin<I, O>
impl<I, O> Default for CommandPlugin<I, O>
Source§impl<I, O> Plugin for CommandPlugin<I, O>
impl<I, O> Plugin for CommandPlugin<I, O>
Source§fn ready(&self, _app: &App) -> bool
fn ready(&self, _app: &App) -> bool
finish should be called.Source§fn finish(&self, _app: &mut App)
fn finish(&self, _app: &mut App)
App, once all plugins registered are ready. This can
be useful for plugins that depends on another plugin asynchronous setup, like the renderer.Source§fn cleanup(&self, _app: &mut App)
fn cleanup(&self, _app: &mut App)
Auto Trait Implementations§
impl<I = (), O = ()> !Freeze for CommandPlugin<I, O>
impl<I, O> RefUnwindSafe for CommandPlugin<I, O>where
I: RefUnwindSafe,
O: RefUnwindSafe,
impl<I, O> Send for CommandPlugin<I, O>
impl<I, O> Sync for CommandPlugin<I, O>
impl<I, O> Unpin for CommandPlugin<I, O>
impl<I, O> UnwindSafe for CommandPlugin<I, O>where
I: UnwindSafe,
O: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more