Skip to main content

AggregateIdGenerator

Trait AggregateIdGenerator 

Source
pub trait AggregateIdGenerator<A: Aggregate + CommandHandler>: MaybeSend + MaybeSync {
    // Required method
    fn next_id(&self, cmd: &A::CreateCommand, ctx: &CqrsContext) -> String;
}
Expand description

Trait for generating aggregate IDs during creation.

The default implementation (DefaultIdGenerator) generates a UUID v4. Implement this trait to derive the aggregate ID from the create command, which is useful for association-as-aggregate patterns where the ID must be deterministic (e.g., composed from two entity IDs).

Required Methods§

Source

fn next_id(&self, cmd: &A::CreateCommand, ctx: &CqrsContext) -> String

Implementors§