[][src]Derive Macro domain_derive::DomainEvent

#[derive(DomainEvent)]

The DomainEvent macro should be applied to a struct that represents a DomainEvent. It completely implements all methods of the DomainEvent trait, as long as some preconditions are met:

  1. You are applying this to a struct.
  2. There needs to be an id field of type Uuid.
  3. There needs to be a version field of any integer type (floating point not allowed).
  4. There needs to be an aggregate_id field of type Uuid.
  5. There needs to be an occurred field of type i64.
This code runs with edition 2018
#[macro_use]
extern crate domain_derive;

use uuid::Uuid;
use domain_patterns::event::DomainEvent;

#[derive(Serialize, Clone, DomainEvent)]
pub struct FirstNameUpdatedEvent {
    pub id: Uuid,
    pub aggregate_id: String,
    pub first_name: String,
    pub version: u64,
    pub occurred: i64,
}