pub trait RealtimeBus:
Send
+ Sync
+ Debug {
// Required methods
fn subscribe(&self, topic: EntityTopic) -> Option<Receiver<LiveEvent>>;
fn subscriber_count(&self, topic: EntityTopic) -> usize;
fn publish(&self, event: LiveEvent) -> Result<(), RealtimePublishError>;
}Expand description
Backend-neutral realtime change bus.
The SSE handler (live.rs) depends only on this trait, so the concrete
source — SurrealDB live queries (surreal_bus::LiveQueryBus) or Postgres
LISTEN/NOTIFY ([postgres_bus::PostgresNotifyBus]) — can be swapped at
startup based on the configured persistence backend.
Required Methods§
Sourcefn subscribe(&self, topic: EntityTopic) -> Option<Receiver<LiveEvent>>
fn subscribe(&self, topic: EntityTopic) -> Option<Receiver<LiveEvent>>
Subscribe to a topic’s broadcast stream. None when the topic is not
enrolled on this bus.
Sourcefn subscriber_count(&self, topic: EntityTopic) -> usize
fn subscriber_count(&self, topic: EntityTopic) -> usize
Number of active subscribers on a topic (for observability).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".