Skip to main content

Event

Trait Event 

Source
pub trait Event:
    Serialize
    + DeserializeOwned
    + Send
    + Sync
    + 'static {
    // Required methods
    fn subject(&self) -> Cow<'_, str>;
    fn message_id(&self) -> MessageId;

    // Provided method
    fn aggregate_type() -> &'static str
       where Self: Sized { ... }
}
Expand description

Marker trait for all events published through the event bus.

Implement manually or use #[derive(Event)] from the bus-macros crate. Every implementor must have a stable, unique message_id() for idempotency and deduplication.

Required Methods§

Source

fn subject(&self) -> Cow<'_, str>

NATS subject for this event.

Source

fn message_id(&self) -> MessageId

Unique identifier used as the message ID header and idempotency key.

Provided Methods§

Source

fn aggregate_type() -> &'static str
where Self: Sized,

Aggregate type used for outbox routing.

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.

Implementors§