Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
eventide-domain
中文版本: README.zh.md
Domain layer of the eventide
DDD/CQRS toolkit. This crate ships the pure-Rust building blocks that
your business logic actually depends on — and only those. It has no
database driver, no message broker, and no HTTP framework.
What is in here
| Module | Highlights |
|---|---|
aggregate |
Aggregate trait (TYPE, Command, Event, Error, execute, apply). |
aggregate_root |
AggregateRoot<A, R> orchestrating load → execute → apply → save. |
entity |
Entity trait with id / version for optimistic concurrency. |
value_object |
ValueObject marker trait and Version newtype. |
domain_event |
DomainEvent trait, EventEnvelope, EventContext, Metadata, FieldChanged. |
event_upcaster |
EventUpcaster + EventUpcasterChain for evolving event schemas. |
persist |
EventRepository, SnapshotRepository, AggregateRepository and reusable adapters. |
eventing |
Optional async event subsystem (bus / engine / dispatcher / reclaimer) on tokio. |
specification |
Specification<T> combinator pattern (and, or, not). |
error |
DomainError, ErrorKind, ErrorCode for typed domain failures. |
Add it
[]
= "0.1"
The macro-generated Serialize / Deserialize derives route through
this crate's internal serde re-export, so #[entity], #[entity_id],
#[domain_event] and #[value_object] work without a direct serde
dependency. The crate also re-exports eventide_domain::async_trait
(write #[async_trait] on your own trait impls) and
eventide_domain::tokio (runtime, gated on the eventing feature).
Add serde / tokio / async-trait to your own Cargo.toml only
when you reach for them outside these re-exports (extra derives,
custom #[serde(...)] attributes, advanced runtime features).
Or pull everything in via the umbrella crate:
[]
= "0.1"
Feature flags
| Flag | Default | What it enables |
|---|---|---|
eventing |
yes | Asynchronous event subsystem (bus / engine / dispatcher / reclaimer). Pulls in tokio and futures-util. |
infra-sqlx |
no | sqlx conversions on SerializedEvent / SerializedSnapshot for Postgres-backed event stores. |
Disable eventing when you only need pure aggregate modelling:
[]
= { = "0.1", = false }
Macros
The companion crate eventide-macros
generates the boilerplate (Entity, DomainEvent, etc.). The generated
code uses absolute paths ::eventide_domain::..., and this crate exposes
a self-alias so the macros also resolve inside its own tests:
// src/lib.rs
extern crate self as eventide_domain;
Repository helpers
use Arc;
use EventUpcasterChain;
use ;
let upcasters = new;
let event_repo = new;
let snapshot_repo = new;
// Pure event sourcing.
let es = new;
// Event sourcing + snapshots.
let snap = new;
Examples
Layered architecture
eventide-domain is the centre of the dependency graph:
eventide-application → eventide-domain ← eventide-macros
↑
└──── (optional) infra-sqlx
The domain crate intentionally never imports application or infrastructure types, which keeps your business logic pure and trivially testable.
License
Licensed under either of Apache-2.0 or MIT at your option.