pub trait Event:
Serialize
+ Send
+ Sync
+ 'static {
const ID: &'static str;
// Provided methods
fn id(&self) -> &str { ... }
fn schema(&self) -> Option<Value> { ... }
}Expand description
A typed event payload.
Implementations pair a compile-time string id with a Serialize
payload. The struct itself is the payload — serde_json::to_value
on an instance produces what goes on the wire.
§Compile-time vs runtime events
- Compile-time:
const ID/const DESCRIPTIONand the#[event]macro. The defaults foridanddescriptionread these constants. - Runtime: use
DynEventto supply an ownedStringid, description, and payload.DynEventimplementsEventby overriding the instance-level methods.
Both paths emit through the same
emit entry point.
Required Associated Constants§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.