Skip to main content

QueryHandler

Trait QueryHandler 

Source
pub trait QueryHandler<Q: Query>: Send + Sync {
    type Error: Error + Send + Sync;

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

Handler for executing queries.

Query handlers retrieve data from read models and should be optimized for read performance.

Required Associated Types§

Source

type Error: Error + Send + Sync

Error type for query execution failures.

Required Methods§

Source

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

Execute the query 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, F, S> QueryHandler<GenericGetQuery<E>> for GenericQueryHandler<E, F, S>
where E: Clone + Send + Sync + 'static, F: Clone + Send + Sync + Default + 'static, S: CqrsReadService<E>,