pub struct WebSocketSubscriptionStream { /* private fields */ }Expand description
A connected WebSocket subscription whose background reader surfaces delivered messages.
Implementations§
Source§impl WebSocketSubscriptionStream
impl WebSocketSubscriptionStream
Sourcepub fn open(
address: &str,
channel: &str,
accepted_schemas: Vec<SchemaId>,
) -> Result<Self, SdkError>
pub fn open( address: &str, channel: &str, accepted_schemas: Vec<SchemaId>, ) -> Result<Self, SdkError>
Connects to the ws:// address, performs the liminal handshake,
subscribes to channel, and starts the background reader.
Deliveries the server coalesces with the SubscribeAck are retained
and surfaced first, never dropped.
§Errors
Returns SdkError::Connection when the client unit refuses the
open or the socket cannot be opened, and SdkError::Protocol when
the handshake or subscribe is rejected.
Sourcepub fn open_with_auth(
address: &str,
channel: &str,
accepted_schemas: Vec<SchemaId>,
auth_token: &[u8],
) -> Result<Self, SdkError>
pub fn open_with_auth( address: &str, channel: &str, accepted_schemas: Vec<SchemaId>, auth_token: &[u8], ) -> Result<Self, SdkError>
Connects to the ws:// address, performs the liminal handshake
carrying auth_token, subscribes to channel, and starts the
background reader.
A subscription owns a dedicated connection (the v1 shape), so it
presents its own credential in its own Connect frame; the token a
request/response transport was built with lives on that transport’s
socket and cannot travel here. Additive to open: an empty token is
exactly the open-access handshake open performs, so an ungated server
sees byte-identical bytes either way. TCP parity with
SubscriptionStream::open_with_auth.
§Errors
Returns SdkError::Connection when the client unit refuses the open,
the socket cannot be opened, or the token is rejected, and
SdkError::Protocol when the subscribe is rejected.
Sourcepub fn recv_timeout(
&self,
timeout: Duration,
) -> Result<WebSocketDeliveredMessage, SdkError>
pub fn recv_timeout( &self, timeout: Duration, ) -> Result<WebSocketDeliveredMessage, SdkError>
Blocks up to timeout for the next delivered message.
§Errors
Returns SdkError::Connection when no message arrives within
timeout or the background reader has stopped.
Sourcepub const fn subscription_id(&self) -> u64
pub const fn subscription_id(&self) -> u64
The server-assigned id for this subscription.
Sourcepub fn reconnect_state(&self) -> ReconnectState
pub fn reconnect_state(&self) -> ReconnectState
The client unit’s reconnect state for this subscription’s connection.