Trait Event

Source
pub trait Event:
    Send
    + Sync
    + Debug {
    // Required methods
    fn event_type(&self) -> &'static str;
    fn source(&self) -> &str;
    fn metadata(&self) -> &Metadata;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn timestamp(&self) -> DateTime<Utc> { ... }
    fn correlation_id(&self) -> Option<Uuid> { ... }
    fn priority(&self) -> EventPriority { ... }
    fn should_persist(&self) -> bool { ... }
}
Expand description

Base event trait that all events must implement

Required Methods§

Source

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

Get the event type identifier

Source

fn source(&self) -> &str

Get the event source

Source

fn metadata(&self) -> &Metadata

Get event metadata

Source

fn as_any(&self) -> &dyn Any

Get event as Any for downcasting

Provided Methods§

Source

fn timestamp(&self) -> DateTime<Utc>

Get event timestamp (default implementation)

Source

fn correlation_id(&self) -> Option<Uuid>

Get event correlation ID if available

Source

fn priority(&self) -> EventPriority

Get event priority (default is normal)

Source

fn should_persist(&self) -> bool

Whether this event should be persisted

Implementors§