use ddd_cqrs_es::DomainEvent;
// =========================================================================
// Define Domain Events (The Facts)
// =========================================================================
// Events must represent historical facts that have already occurred. They
// must be stable, immutable, and serializable.
#[derive(Clone, Debug, PartialEq)]
pub enum BankAccountEvent {
AccountOpened {
account_id: String,
owner: String,
},
MoneyDeposited {
amount: u64,
},
MoneyWithdrawn {
amount: u64,
},
}
impl DomainEvent for BankAccountEvent {
// Unique identifier for the event schema, useful for adapters or databases
fn event_type(&self) -> &'static str {
match self {
BankAccountEvent::AccountOpened { .. } => "bank_account_opened",
BankAccountEvent::MoneyDeposited { .. } => "money_deposited",
BankAccountEvent::MoneyWithdrawn { .. } => "money_withdrawn",
}
}
}