cqrs_es2/queries/
query_context.rs1use log::trace;
2use std::{
3 fmt::Debug,
4 marker::PhantomData,
5};
6
7use crate::{
8 commands::ICommand,
9 events::IEvent,
10};
11
12use super::i_query::IQuery;
13
14#[derive(Debug, PartialEq, Clone)]
17pub struct QueryContext<C: ICommand, E: IEvent, Q: IQuery<C, E>> {
18 pub aggregate_id: String,
20
21 pub version: i64,
23
24 pub payload: Q,
26
27 _phantom: PhantomData<(C, E)>,
28}
29
30impl<C: ICommand, E: IEvent, Q: IQuery<C, E>> QueryContext<C, E, Q> {
31 pub fn new(
33 aggregate_id: String,
34 version: i64,
35 payload: Q,
36 ) -> Self {
37 let x = Self {
38 aggregate_id,
39 version,
40 payload,
41 _phantom: PhantomData,
42 };
43
44 trace!("Created new {:?}", x,);
45
46 x
47 }
48}