EntityEvent

Trait EntityEvent 

Source
pub trait EntityEvent:
    Send
    + Sync
    + Debug {
    type Id;

    // Required methods
    fn kind(&self) -> EventKind;
    fn entity_id(&self) -> &Self::Id;
}
Expand description

Base trait for entity lifecycle events.

Generated event enums implement this trait, enabling generic event handling and dispatching.

§Example

fn handle_event<E: EntityEvent>(event: &E) {
    println!("Event {:?} for entity {:?}", event.kind(), event.entity_id());
}

Required Associated Types§

Source

type Id

Type of entity ID.

Required Methods§

Source

fn kind(&self) -> EventKind

Get the kind of event.

Source

fn entity_id(&self) -> &Self::Id

Get the entity ID associated with this event.

Implementors§