1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use cqrs_es2::{
    Aggregate,
    AggregateContext,
};

/// Holds context for a pure event store implementation for MemStore
pub struct PostgresStoreAggregateContext<A: Aggregate> {
    /// The aggregate ID of the aggregate instance that has been
    /// loaded.
    pub aggregate_id: String,
    /// The current state of the aggregate instance.
    pub aggregate: A,
    /// The last committed event sequence number for this aggregate
    /// instance.
    pub current_sequence: usize,
}

impl<A: Aggregate> AggregateContext<A>
    for PostgresStoreAggregateContext<A>
{
    fn aggregate(&self) -> &A {
        &self.aggregate
    }
}