pub trait Apply<E> {
// Required method
fn apply(&mut self, event: &E);
}Expand description
Mutate an aggregate with a domain event.
Apply<E> is called while the repository rebuilds aggregate state, keeping
the domain logic focused on pure events rather than persistence concerns.
ⓘ
#[derive(Default)]
struct Account {
balance: i64,
}
impl Apply<FundsDeposited> for Account {
fn apply(&mut self, event: &FundsDeposited) {
self.balance += event.amount;
}
}