pub trait Aggregate: Sized + Default {
type ReplayError: Display;
// Required methods
fn entity(&self) -> &Entity;
fn entity_mut(&mut self) -> &mut Entity;
fn replay_event(
&mut self,
event: &EventRecord,
) -> Result<(), Self::ReplayError>;
// Provided methods
fn aggregate_type() -> &'static str { ... }
fn new_empty() -> Self { ... }
fn upcasters() -> &'static [EventUpcaster] { ... }
}Expand description
Trait for domain aggregates that can be event-sourced.
Required Associated Types§
type ReplayError: Display
Required Methods§
fn entity(&self) -> &Entity
fn entity_mut(&mut self) -> &mut Entity
fn replay_event(&mut self, event: &EventRecord) -> Result<(), Self::ReplayError>
Provided Methods§
Sourcefn aggregate_type() -> &'static str
fn aggregate_type() -> &'static str
Stable aggregate type used by stream-aware persistence.
The default is a development fallback based on Rust’s type name so existing examples keep working. Production persistence should override this with an explicit, durable application name.
fn new_empty() -> Self
Sourcefn upcasters() -> &'static [EventUpcaster]
fn upcasters() -> &'static [EventUpcaster]
Override to register upcasters for this aggregate’s events. Upcasters are configuration, not state — this is a static method.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".