pub trait Handle<C>: Aggregate {
// Required method
fn handle(&self, command: &C) -> Result<Vec<Self::Event>, Self::Error>;
}Expand description
Entry point for command handling.
Each command type gets its own implementation, letting the aggregate express validation logic in a strongly typed way.
ⓘ
impl Handle<DepositFunds> for Account {
fn handle(&self, command: &DepositFunds) -> Result<Vec<Self::Event>, Self::Error> {
if command.amount <= 0 {
return Err("amount must be positive".into());
}
Ok(vec![FundsDeposited { amount: command.amount }.into()])
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.