Skip to main content

dispatch_command

Macro dispatch_command 

Source
macro_rules! dispatch_command {
    ($payload:expr, $cmd:expr, $state:expr, $seq:expr, { $($suffix:literal => $handler:expr),* $(,)? }) => { ... };
}
Expand description

Helper macro for dispatching commands by type URL suffix.

Similar to dispatch_event! but for command handler handlers.

§Example

use angzarr_client::dispatch_command;

impl CommandHandlerDomainHandler for PlayerHandler {
    fn handle(
        &self,
        cmd: &CommandBook,
        payload: &Any,
        state: &PlayerState,
        seq: u32,
    ) -> CommandResult<EventBook> {
        dispatch_command!(payload, cmd, state, seq, {
            "RegisterPlayer" => self.handle_register,
            "DepositFunds" => self.handle_deposit,
        })
    }
}