Skip to main content

CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler<C: Command>: Send + Sync {
    type Error: Error + Send + Sync;

    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        command: C,
    ) -> Pin<Box<dyn Future<Output = Result<C::Result, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Handler for executing commands.

Each command type should have exactly one handler. Handlers contain the business logic for processing commands.

Required Associated Types§

Source

type Error: Error + Send + Sync

Error type for command execution failures.

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, command: C, ) -> Pin<Box<dyn Future<Output = Result<C::Result, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the command and return the result.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E, C, U, S> CommandHandler<GenericCreateCommand<E, C>> for GenericCommandHandler<E, C, U, S>
where E: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, U: Clone + Send + Sync + 'static, S: CqrsService<E, C, U>,

Source§

impl<E, C, U, S> CommandHandler<GenericDeleteCommand<E>> for GenericCommandHandler<E, C, U, S>
where E: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, U: Clone + Send + Sync + 'static, S: CqrsService<E, C, U>,

Source§

impl<E, C, U, S> CommandHandler<GenericUpdateCommand<E, U>> for GenericCommandHandler<E, C, U, S>
where E: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, U: Clone + Send + Sync + 'static, S: CqrsService<E, C, U>,