pub struct WsSubscriber { /* private fields */ }Expand description
Handle to a running WS subscriber task.
Dropping the handle does not stop the task — use
WsSubscriber::shutdown for a clean exit. This is deliberate:
the TUI passes the handle around via Arc and the subscriber
outlives widgets that only need to subscribe to events.
Implementations§
Source§impl WsSubscriber
impl WsSubscriber
Sourcepub fn spawn(
url: &str,
token: Option<String>,
state: Arc<RwLock<EngineState>>,
) -> Result<Self, WsError>
pub fn spawn( url: &str, token: Option<String>, state: Arc<RwLock<EngineState>>, ) -> Result<Self, WsError>
Spawn a subscriber against url, authenticating with
token if provided.
Returns immediately; the connect attempt happens in the
background task. Consumers poll EngineState::connection
on the shared state to learn whether the first connection
has landed.
§Errors
Returns WsError::InvalidUrl if the url cannot be parsed.
Sourcepub fn spawn_with_config(
url: &str,
token: Option<String>,
state: Arc<RwLock<EngineState>>,
reconnect: ReconnectConfig,
) -> Result<Self, WsError>
pub fn spawn_with_config( url: &str, token: Option<String>, state: Arc<RwLock<EngineState>>, reconnect: ReconnectConfig, ) -> Result<Self, WsError>
Like Self::spawn with a custom reconnect policy; used by
tests that want to exercise backoff without real wall-clock
delay.
§Errors
Returns WsError::InvalidUrl if the url cannot be parsed.
Sourcepub fn state(&self) -> Arc<RwLock<EngineState>>
pub fn state(&self) -> Arc<RwLock<EngineState>>
Shared handle to the engine-state mirror. Widgets clone this
and acquire .read() for the duration of a render pass.
Sourcepub fn events(&self) -> Receiver<EngineEvent>
pub fn events(&self) -> Receiver<EngineEvent>
Subscribe to the raw typed event stream. Each subscriber gets its own receiver; slow consumers are dropped by tokio’s broadcast channel, which is appropriate for a push firehose.