pub struct RequestStream<S> { /* private fields */ }Expand description
Decode S type into Stream of websocket Message.
S type must impl Stream trait and output Result<T, E> as Stream::Item
where T type impl AsRef<[u8]> trait. (&[u8] is needed for parsing messages)
§Stream termination
This stream never returns None. Callers should expect one of the following outcomes:
Ok(Message::Close(_)): The remote peer initiated a clean close. The caller should send a close frame back via ResponseSender and then stop polling.Err(WsError::Protocol(ProtocolError::RecvClosed)): The stream was polled after a close frame had already been received. The caller should have stopped polling after observingMessage::Close.Err(WsError::Protocol(ProtocolError::UnexpectedEof)): The underlying transport ended without a close frame. This is an abnormal closure and the associated connection should not be reused.Err(WsError::Protocol(_)): A protocol violation occurred (e.g. bad opcode, continuation error). The connection should be dropped.Err(WsError::Stream(_)): The underlying stream produced an error.
Implementations§
Source§impl<S, T, E> RequestStream<S>
impl<S, T, E> RequestStream<S>
pub fn new(stream: S) -> Self
pub fn with_codec(stream: S, codec: Codec) -> Self
pub fn inner_mut(&mut self) -> &mut S
pub fn codec_mut(&mut self) -> &mut Codec
Sourcepub fn response_stream(&self) -> (ResponseStream, ResponseSender)
pub fn response_stream(&self) -> (ResponseStream, ResponseSender)
Make a ResponseStream from current DecodeStream.
This API is to share the same codec for both decode and encode stream.
Trait Implementations§
Source§impl<S, T, E> Stream for RequestStream<S>
impl<S, T, E> Stream for RequestStream<S>
impl<'__pin, S> Unpin for RequestStream<S>where
PinnedFieldsOf<__Origin<'__pin, S>>: Unpin,
Auto Trait Implementations§
impl<S> Freeze for RequestStream<S>where
S: Freeze,
impl<S> RefUnwindSafe for RequestStream<S>where
S: RefUnwindSafe,
impl<S> Send for RequestStream<S>where
S: Send,
impl<S> Sync for RequestStream<S>where
S: Sync,
impl<S> UnsafeUnpin for RequestStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for RequestStream<S>where
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