Skip to main content

QueryHandler

Trait QueryHandler 

Source
pub trait QueryHandler<Q, R>: Send + Sync {
    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 AppContext,
        q: Q,
    ) -> Pin<Box<dyn Future<Output = Result<R, AppError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

查询处理器(Query Handler)

  • 处理具体类型的查询,返回结果对象/类型;
  • 建议只读,不修改领域状态,可直接访问读模型或投影。

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 AppContext, q: Q, ) -> Pin<Box<dyn Future<Output = Result<R, AppError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

处理查询并返回结果对象/类型

Implementors§