pub trait CommandBus: Send + Sync {
// Required method
fn dispatch<'life0, 'life1, 'async_trait, C, R>(
&'life0 self,
ctx: &'life1 AppContext,
cmd: C,
) -> Pin<Box<dyn Future<Output = Result<R, AppError>> + Send + 'async_trait>>
where C: Send + 'static + 'async_trait,
R: Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
命令总线(Command Bus)
- 负责根据命令的具体类型路由到对应的处理器;
- 框架可提供不同实现(如进程内、消息队列等);
- 该 trait 带有泛型方法,通常以具体实现类型注入使用。
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.