Skip to main content

Event

Trait Event 

Source
pub trait Event:
    Send
    + Sync
    + Debug
    + 'static {
    // Provided methods
    fn priority(&self) -> u32 { ... }
    fn batchable(&self) -> bool { ... }
}
Expand description

Trait for all IPC events.

Events are the primary communication mechanism between kernel subsystems, drivers, and modules. All events must be:

  • Send + Sync for cross-thread dispatch
  • Debug for logging and diagnostics
  • 'static for type-erased storage

§Priority System

Events have a priority that affects handler dispatch order:

  • 0-50: Core/critical handlers (run first)
  • 100: Default priority
  • 200+: Low priority (cleanup, logging)

Lower priority numbers mean earlier dispatch.

§Batching

Events can opt into batching for future optimization. When batchable() returns true, the event bus may combine multiple events of the same type into a single dispatch when under load.

§Targeted Events

For events that target specific components, implement TargetedEvent in addition to Event. This allows using EventBus::subscribe_targeted() for automatic filtering by target.

Provided Methods§

Source

fn priority(&self) -> u32

Priority for handler dispatch ordering.

Lower values = earlier dispatch. Default is 100 (normal priority).

Convention:

  • 0-50: Core handlers
  • 100: Default/plugin handlers
  • 200+: Low priority (logging, cleanup)
Source

fn batchable(&self) -> bool

Whether this event can be batched with similar events.

Default is false. When true, the event bus may combine multiple events of the same type into a single dispatch for efficiency.

Implementors§