Skip to main content

appletheia_application/command/
command_dispatcher.rs

1use crate::command::{Command, CommandDispatchError, CommandHandler};
2use crate::request_context::RequestContext;
3use crate::unit_of_work::UnitOfWork;
4
5#[allow(async_fn_in_trait)]
6pub trait CommandDispatcher: Send + Sync {
7    type Uow: UnitOfWork;
8
9    async fn dispatch<H>(
10        &self,
11        handler: &H,
12        request_context: &RequestContext,
13        command: H::Command,
14    ) -> Result<H::Output, CommandDispatchError<H::Error>>
15    where
16        H: CommandHandler<Uow = Self::Uow>,
17        H::Command: Command;
18}