pub trait EventSubscriber: Send + Sync {
// Required method
fn send_text<'life0, 'async_trait>(
&'life0 self,
json: String,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
A live sink the host broadcasts host.event JSON-RPC frames to. Implemented
by the WebSocket connection (WsChannel, in session.rs).
Abstracting subscribers behind this trait is the load-bearing decoupling for
the #418 car-server-core decomposition: it removes HostState’s only concrete
dependency on the WS type (WsChannel), so HostState (and the
approval_core / channel / messaging surfaces that sit on it) can later move
to a lower crate without dragging the tokio-tungstenite stack along, and
without a dependency cycle back to car-server-core.
Required Methods§
Sourcefn send_text<'life0, 'async_trait>(
&'life0 self,
json: String,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn send_text<'life0, 'async_trait>(
&'life0 self,
json: String,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send a pre-serialized JSON-RPC frame. Best-effort: a wedged/closed socket
is reaped by the next unsubscribe, not surfaced as an error here.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl EventSubscriber for WsChannel
A WS connection is a host event sink (#418): HostState broadcasts
host.event frames to subscribers through this trait, so it never has to
know about the concrete WsChannel / tungstenite types.