macro_rules! command_registry {
() => { ... };
($($handler:expr),*$(,)?) => { ... };
($($command:ty => $handler:expr),*$(,)?) => { ... };
}
Expand description
A macro for creating a CommandHandlerRegistry
instance.
This macro provides a convenient way to initialize a CommandHandlerRegistry
and register multiple
command handlers at once.
§Usage
You can use this macro in two ways:
- Providing only handlers:
use discern::command_registry;
let command_registry = command_registry! {
CreateUserCommandHandler { /* ... */ },
};
This assumes that the types of the handlers can be inferred automatically.
- Providing type-handler pairs:
use discern::command_registry;
let command_registry = command_registry! {
CreateUserCommand => CreateUserCommandHandler { /* ... */ },
};
This explicitly specifies the command type associated with each handler.