Expand description
This reader bundles an existing stream with a parsing algorithm.
It is used by the client in its .split()
function as the reading component.
Fields
stream: BufReader<R>
the stream to be read from
receiver: Receiver
the parser to parse bytes into messages
Implementations
sourceimpl<R> Reader<R> where
R: Read,
impl<R> Reader<R> where
R: Read,
sourcepub fn recv_dataframe(&mut self) -> WebSocketResult<DataFrame>
pub fn recv_dataframe(&mut self) -> WebSocketResult<DataFrame>
Reads a single data frame from the remote endpoint.
sourcepub fn incoming_dataframes(
&mut self
) -> DataFrameIterator<'_, Receiver, BufReader<R>>ⓘNotable traits for DataFrameIterator<'a, Recv, R>impl<'a, Recv, R> Iterator for DataFrameIterator<'a, Recv, R> where
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::F, WebSocketError>;
pub fn incoming_dataframes(
&mut self
) -> DataFrameIterator<'_, Receiver, BufReader<R>>ⓘNotable traits for DataFrameIterator<'a, Recv, R>impl<'a, Recv, R> Iterator for DataFrameIterator<'a, Recv, R> where
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::F, WebSocketError>;
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::F, WebSocketError>;
Returns an iterator over incoming data frames.
sourcepub fn recv_message(&mut self) -> WebSocketResult<OwnedMessage>
pub fn recv_message(&mut self) -> WebSocketResult<OwnedMessage>
Reads a single message from this receiver.
sourcepub fn incoming_messages<'a>(
&'a mut self
) -> MessageIterator<'a, Receiver, BufReader<R>>ⓘNotable traits for MessageIterator<'a, Recv, R>impl<'a, Recv, R> Iterator for MessageIterator<'a, Recv, R> where
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::M, WebSocketError>;
pub fn incoming_messages<'a>(
&'a mut self
) -> MessageIterator<'a, Receiver, BufReader<R>>ⓘNotable traits for MessageIterator<'a, Recv, R>impl<'a, Recv, R> Iterator for MessageIterator<'a, Recv, R> where
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::M, WebSocketError>;
Recv: 'a + Receiver,
R: Read, type Item = Result<<Recv as Receiver>::M, WebSocketError>;
An iterator over incoming messsages. This iterator will block until new messages arrive and will never halt.
sourceimpl<S> Reader<S> where
S: AsTcpStream + Stream + Read,
impl<S> Reader<S> where
S: AsTcpStream + Stream + Read,
sourcepub fn shutdown(&self) -> IoResult<()>
pub fn shutdown(&self) -> IoResult<()>
Closes the receiver side of the connection, will cause all pending and future IO to return immediately with an appropriate value.
sourcepub fn shutdown_all(&self) -> IoResult<()>
pub fn shutdown_all(&self) -> IoResult<()>
Shuts down both Sender and Receiver, will cause all pending and future IO to return immediately with an appropriate value.
Auto Trait Implementations
impl<R> RefUnwindSafe for Reader<R> where
R: RefUnwindSafe,
impl<R> Send for Reader<R> where
R: Send,
impl<R> Sync for Reader<R> where
R: Sync,
impl<R> Unpin for Reader<R> where
R: Unpin,
impl<R> UnwindSafe for Reader<R> where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more