pub struct CommandBus<E>where
E: Event,{ /* private fields */ }Expand description
Command Bus for dispatching commands to handlers
Implementations§
Source§impl<E> CommandBus<E>where
E: Event,
impl<E> CommandBus<E>where
E: Event,
Sourcepub fn new() -> CommandBus<E>
pub fn new() -> CommandBus<E>
Create a new command bus
Sourcepub async fn register<C, H>(&self, handler: H)where
C: Command,
H: CommandHandler<C, E> + 'static,
pub async fn register<C, H>(&self, handler: H)where
C: Command,
H: CommandHandler<C, E> + 'static,
Register a command handler
Sourcepub async fn dispatch<C>(&self, command: C) -> Result<Vec<E>, CommandError>where
C: Command,
pub async fn dispatch<C>(&self, command: C) -> Result<Vec<E>, CommandError>where
C: Command,
Dispatch a command
Sourcepub async fn dispatch_idempotent<C>(
&self,
command: C,
idempotency_key: String,
) -> Result<Vec<E>, CommandError>where
C: Command,
pub async fn dispatch_idempotent<C>(
&self,
command: C,
idempotency_key: String,
) -> Result<Vec<E>, CommandError>where
C: Command,
Dispatch a command with idempotency key
Sourcepub async fn handlers_count(&self) -> usize
pub async fn handlers_count(&self) -> usize
Get number of registered handlers
Trait Implementations§
Source§impl<E> Clone for CommandBus<E>where
E: Event,
impl<E> Clone for CommandBus<E>where
E: Event,
Source§fn clone(&self) -> CommandBus<E>
fn clone(&self) -> CommandBus<E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E> Default for CommandBus<E>where
E: Event,
impl<E> Default for CommandBus<E>where
E: Event,
Source§fn default() -> CommandBus<E>
fn default() -> CommandBus<E>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<E> Freeze for CommandBus<E>
impl<E> !RefUnwindSafe for CommandBus<E>
impl<E> Send for CommandBus<E>
impl<E> Sync for CommandBus<E>
impl<E> Unpin for CommandBus<E>
impl<E> !UnwindSafe for CommandBus<E>
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