eventcore-macros 1.0.1

Procedural macros for EventCore event sourcing library
Documentation

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 type StreamId (or eventcore::StreamId).