Skip to main content

Module ddd

Module ddd 

Source
Expand description

Domain-Driven-Design primitives shared by every pattern.

These traits are the vocabulary: an AggregateRoot is the transactional consistency boundary, a Command requests a state change inside one, a DomainEvent records the fact that the change happened, an Entity is anything with a stable identity, and a ValueObject is anything whose identity is its value. The Repository is how callers reach an aggregate.

Traits§

AggregateRoot
DDD aggregate root. One per consistency boundary; every command and every event passes through one of these.
Command
A command targets exactly one crate::AggregateRoot (the transactional consistency boundary). The framework needs to know which aggregate before it can route the command, so every command must surface its target id.
DomainEvent
A persisted fact. Supplies optional metadata the read side needs:
Entity
A domain object that is identified by its Id, not by its attribute values. Two Entity instances with the same Id represent the same conceptual thing even if their other fields differ.
Repository
Send commands to an aggregate; receive the events that resulted (or the typed domain error if the command was rejected).
ValueObject
Marker trait for value objects: domain types that are immutable, compared by value, and have no independent identity. Money, ranges, addresses, codes — anything that, if you mutated it, would no longer be the same value.