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§
Sourcefn event_type(&self) -> &'static str
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§
Sourcefn schema_version(&self) -> u32
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".