Skip to main content

Crate eventcore_macros

Crate eventcore_macros 

Source
Expand description

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).

Derive Macros§

Command
Entry point for #[derive(Command)].