pub struct CommandBus { /* private fields */ }Expand description
In-memory command bus that routes envelopes to registered handlers.
Implementations§
Source§impl CommandBus
impl CommandBus
Sourcepub fn register_handler<H: CommandHandler + 'static>(
&mut self,
handler: H,
) -> RuntimeResult<()>
pub fn register_handler<H: CommandHandler + 'static>( &mut self, handler: H, ) -> RuntimeResult<()>
Registers one handler, rejecting duplicate command names.
Sourcepub fn contains_handler(&self, name: &CommandName) -> bool
pub fn contains_handler(&self, name: &CommandName) -> bool
Reports whether a handler exists for name.
Sourcepub fn dispatch(
&self,
command: &CommandEnvelope,
context: &dyn RuntimeContext,
) -> RuntimeResult<CommandResult>
pub fn dispatch( &self, command: &CommandEnvelope, context: &dyn RuntimeContext, ) -> RuntimeResult<CommandResult>
Dispatches an envelope to the handler matching its command name.
Trait Implementations§
Source§impl Debug for CommandBus
impl Debug for CommandBus
Source§impl Default for CommandBus
impl Default for CommandBus
Source§fn default() -> CommandBus
fn default() -> CommandBus
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for CommandBus
impl !UnwindSafe for CommandBus
impl Freeze for CommandBus
impl Send for CommandBus
impl Sync for CommandBus
impl Unpin for CommandBus
impl UnsafeUnpin for CommandBus
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
Mutably borrows from an owned value. Read more