pub struct WebSocketState<T> { /* private fields */ }
Implementations§
source§impl<T: Read + Write> WebSocketState<T>
impl<T: Read + Write> WebSocketState<T>
pub fn new(socket: WebSocket<T>) -> Self
sourcepub fn subscribe<'a>(
&mut self,
streams: impl IntoIterator<Item = &'a Stream>
) -> u64
pub fn subscribe<'a>( &mut self, streams: impl IntoIterator<Item = &'a Stream> ) -> u64
Sends SUBSCRIBE
message for the given streams
.
streams
are not validated. Invalid streams will be
accepted by the server, but no data will be sent.
Requests to subscribe an existing stream will be ignored
by the server.
Returns the message id
. This should be used to match
the request with a future response. Sent messages should
not share the same message id
.
You should expect the server to respond with a similar message.
{ "method": "SUBSCRIBE", "params": [ <streams> ], "id": <id> }
sourcepub fn unsubscribe<'a>(
&mut self,
streams: impl IntoIterator<Item = &'a Stream>
) -> u64
pub fn unsubscribe<'a>( &mut self, streams: impl IntoIterator<Item = &'a Stream> ) -> u64
Sends UNSUBSCRIBE
message for the given streams
.
streams
are not validated. Non-existing streams will be
ignored by the server.
Returns the message id
. This should be used to match
the request with a future response. Sent messages should
not share the same message id
.
You should expect the server to respond with a similar message.
{ "method": "UNSUBSCRIBE", "params": [ <streams> ], "id": <id> }
sourcepub fn subscriptions(&mut self) -> u64
pub fn subscriptions(&mut self) -> u64
Sends LIST_SUBSCRIPTIONS
message.
Returns the message id
. This should be used to match
the request with a future response. Sent messages should
not share the same message id
.
You should expect the server to respond with a similar message.
{ "method": "LIST_SUBSCRIPTIONS", "params": [ <streams> ], "id": <id> }