tsuzuri 0.1.285

Tsuzuri is a Event Sourcing framework for Rust, designed to be simple and easy to use.
Documentation
use crate::message;
use std::fmt;

/// Marker trait for integration events that communicate changes to external systems.
/// Integration events are used for communication between bounded contexts.
pub trait IntegrationEvent: fmt::Debug + message::Message + Send + Sync + 'static {
    fn id(&self) -> String;
    fn event_type(&self) -> &'static str;
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SerializedIntegrationEvent {
    pub id: String,
    pub aggregate_id: String,
    pub aggregate_type: String,
    pub event_type: String,
    pub payload: Vec<u8>,
}

#[allow(dead_code)]
impl SerializedIntegrationEvent {
    pub fn new(id: String, aggregate_id: String, aggregate_type: String, event_type: String, payload: Vec<u8>) -> Self {
        Self {
            id,
            aggregate_id,
            aggregate_type,
            event_type,
            payload,
        }
    }
}