use cqrs_es::{Aggregate, AggregateContext};
pub struct EventStoreAggregateContext<A: Aggregate> {
pub aggregate_id: String,
pub aggregate: A,
pub current_sequence: usize,
}
impl<A: Aggregate> AggregateContext<A> for EventStoreAggregateContext<A> {
fn aggregate(&self) -> &A {
&self.aggregate
}
}
#[derive(Debug, PartialEq)]
pub struct SnapshotStoreAggregateContext<A>
where
A: Aggregate,
{
pub aggregate_id: String,
pub aggregate: A,
pub current_sequence: usize,
pub current_snapshot: usize,
}
impl<A> AggregateContext<A> for SnapshotStoreAggregateContext<A>
where
A: Aggregate,
{
fn aggregate(&self) -> &A {
&self.aggregate
}
}
pub struct QueryContext {
pub view_instance_id: String,
pub version: i64,
}
impl QueryContext {
pub fn new(view_instance_id: String, version: i64) -> Self {
Self {
view_instance_id,
version,
}
}
}