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
Trait Implementations§
Auto Trait Implementations§
impl<S, M, I> RefUnwindSafe for Subscription<S, M, I>where I: RefUnwindSafe, S: RefUnwindSafe,
impl<S, M, I> Send for Subscription<S, M, I>where I: Send, S: Send, <M as Message>::ControlMessage: Send,
impl<S, M, I> Sync for Subscription<S, M, I>where I: Sync, S: Sync, <M as Message>::ControlMessage: Send,
impl<S, M, I> Unpin for Subscription<S, M, I>where I: Unpin, S: Unpin,
impl<S, M, I> UnwindSafe for Subscription<S, M, I>where I: UnwindSafe, S: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more