pub trait DispatchableCommand: Send + Sync {
// Provided methods
fn dispatch_command<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sized + 'static + 'async_trait { ... }
fn command_handler<'async_trait, H>( ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + Default + 'static { ... }
fn command_middleware<'async_trait, M>(
middleware: M,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
M: FnMut(DispatchedCommand, Next<DispatchedCommand, DispatchedCommand>) -> BoxFuture<'static, DispatchedCommand> + Send + Sync + 'async_trait + 'static { ... }
fn soft_command_handler<'async_trait, H>( ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + Default + 'static { ... }
fn register_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static { ... }
fn register_soft_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static { ... }
}Expand description
A type that can be used as a command can implement this trait. Implementing this trait makes it easy to register an handler and to dispatch the command.
Provided Methods§
Sourcefn dispatch_command<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: Sized + 'static + 'async_trait,
fn dispatch_command<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: Sized + 'static + 'async_trait,
Dispatch the command
Sourcefn command_handler<'async_trait, H>() -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
fn command_handler<'async_trait, H>() -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
Register this handler for this command
Sourcefn command_middleware<'async_trait, M>(
middleware: M,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
M: FnMut(DispatchedCommand, Next<DispatchedCommand, DispatchedCommand>) -> BoxFuture<'static, DispatchedCommand> + Send + Sync + 'async_trait + 'static,
fn command_middleware<'async_trait, M>(
middleware: M,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
M: FnMut(DispatchedCommand, Next<DispatchedCommand, DispatchedCommand>) -> BoxFuture<'static, DispatchedCommand> + Send + Sync + 'async_trait + 'static,
Register a middleware on this dispatchable command
Sourcefn soft_command_handler<'async_trait, H>() -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
fn soft_command_handler<'async_trait, H>() -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
Register this handler if the command does not have an existing handler
Sourcefn register_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static,
fn register_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static,
Register the instance as the handler for this command
Sourcefn register_soft_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static,
fn register_soft_command_handler<'async_trait, H>(
handler: H,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
H: 'async_trait + CommandHandler + 'static,
Register the instance as the soft handler for this command