Skip to main content

Module event_bus

Module event_bus 

Source
Expand description

Event bus — a single channel for all async-to-sync boundary crossings.

The event bus decouples the Rust domain layer from any particular consumer (Tauri WebSocket server, native macOS FFI bridge, CLI harness, …). Every “push” event (PTY output, transfer progress, connection status change) is serialised into a CoreEvent and sent over a broadcast channel. A single external callback (registered via set_event_callback) drains the channel and dispatches to the native layer.

This avoids a sprawling FFI surface where every event type needs its own callback registration.

§Thread Safety

  • CoreEvent: Send + Sync.
  • The sender and receiver are behind OnceLock — safe to call from any thread.
  • The broadcast channel has a fixed capacity (1024). If the consumer falls behind, the oldest events are dropped. This is intentional — PTY output and progress events are latency-sensitive, not reliability-sensitive.

Enums§

ConnectionStatus
CoreEvent
All event kinds that cross the async-to-sync boundary.

Functions§

event_sender
Get a sender handle to the event bus. The channel is lazily created on first call with a capacity of 1024 events.
subscribe
Subscribe to all events. Returns a receiver that starts with a RecvError::Lagged for any events produced before this subscription.