DispatchableCommand

Trait DispatchableCommand 

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

Source

fn dispatch_command<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sized + 'static + 'async_trait,

Dispatch the command

Source

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,

Register this handler for this command

Source

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

Source

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,

Register this handler if the command does not have an existing handler

Source

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

Source

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

Implementors§