Skip to main content

EventPayload

Trait EventPayload 

Source
pub trait EventPayload:
    Serialize
    + DeserializeOwned
    + Send
    + Sync
    + 'static {
    // Required method
    fn event_type(&self) -> &'static str;

    // Provided method
    fn schema_version(&self) -> u32 { ... }
}
Expand description

Marker trait for domain event types.

Implementors must be JSON-serializable and carry a stable event_type string that the engine stores in EventEnvelope::event_type for projection routing and observability.

§Example

use mako_engine::workflow::EventPayload;

#[derive(serde::Serialize, serde::Deserialize)]
enum MyEvent { Created { name: String }, Closed }

impl EventPayload for MyEvent {
    fn event_type(&self) -> &'static str {
        match self {
            Self::Created { .. } => "MyCreated",
            Self::Closed       => "MyClosed",
        }
    }
}

Required Methods§

Source

fn event_type(&self) -> &'static str

A stable, unique name for this event variant.

Used in EventEnvelope::event_type. Choose names that survive refactors (e.g. "SupplierChangeInitiated", not "Initiated").

Provided Methods§

Source

fn schema_version(&self) -> u32

Schema version of this event’s payload layout.

Increment when the serialized payload structure changes in a backward-incompatible way. The engine stamps this value into EventEnvelope::schema_version so replay and upcasting tooling can identify which decoder to use.

Defaults to 1.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§