Procedural macros for the EventCore event sourcing library.
This crate provides the #[derive(Command)] macro, which generates a
CommandStreams trait implementation for a command struct. The generated
implementation's stream_declarations() method returns every StreamId
field annotated with #[stream], declaring the event streams that the
command reads and writes within a single atomic consistency boundary.
Usage
Annotate a command struct with #[derive(Command)] and mark each
StreamId field that participates in the consistency boundary with
#[stream]:
use eventcore::{Command, StreamId};
#[derive(Command)]
pub struct TransferFunds {
#[stream]
pub source_account: StreamId,
#[stream]
pub destination_account: StreamId,
pub amount: u64,
}
Requirements
- The derive target must be a struct with named fields (tuple structs are not supported).
- At least one field must carry the
#[stream]attribute. - Every
#[stream]-annotated field must have typeStreamId(oreventcore::StreamId).