Struct websocket_util::subscribe::Subscription
source · pub struct Subscription<S, M, I>where
M: Message,{ /* private fields */ }
Expand description
A subscription associated with a MessageStream
that allows for
sending and receiving control messages over it.
Notes
- in order for any
send
orread
operations to resolve, the associatedMessageStream
stream needs to be polled; that is necessary because this operation expects a control message response and that control message comes through the regular stream.
Implementations§
source§impl<S, M, I> Subscription<S, M, I>where
S: Sink<I> + Unpin,
M: Message,
impl<S, M, I> Subscription<S, M, I>where
S: Sink<I> + Unpin,
M: Message,
sourcepub async fn send(
&mut self,
item: I
) -> Result<Option<Result<M::ControlMessage, ()>>, S::Error>
pub async fn send(
&mut self,
item: I
) -> Result<Option<Result<M::ControlMessage, ()>>, S::Error>
Send a message over the internal control channel and wait a control message response.
The method returns the following errors:
Err(..)
when the sink failed to send an itemOk(None)
when the message stream got closedOk(Some(Err(())))
when message classification reported an error; the actual error still manifests through the message stream