pub async fn read_frame(&mut self) -> crate::Result<Option<Frame>> {
        loop {
            // Attempt to parse a frame from the buffered data. If enough data
            // has been buffered, the frame is returned.
            if let Some(frame) = self.parse_frame()? {
                return Ok(Some(frame));
            }

            // There is not enough buffered data to read a frame. Attempt to
            // read more data from the socket.
            //
            // On success, the number of bytes is returned. `0` indicates "end
            // of stream".
            if 0 == self.stream.read_buf(&mut self.buffer).await? {
                // The remote closed the connection. For this to be a clean
                // shutdown, there should be no data in the read buffer. If
                // there is, this means that the peer closed the socket while
                // sending a frame.
                if self.buffer.is_empty() {
                    return Ok(None);
                } else {
                    let s = "connection reset by peer".into();
                    return Err(s);
                }
            }
        }
    }
/// Read a single `Frame` value from the underlying stream.
///
/// The function waits until it has retrieved enough data to parse a frame.
/// Any data remaining in the read buffer after the frame has been parsed is
/// kept there for the next call to `read_frame`.
///
/// # Returns
///
/// On success, the received frame is returned. If the `TcpStream`
/// is closed in a way that doesn't break a frame in half, it returns
/// `None`. Otherwise, an error is returned.
Read a single `Frame` value from the underlying stream.
The function waits until it has retrieved enough data to parse a frame.
Any data remaining in the read buffer after the frame has been parsed is
kept there for the next call to `read_frame`.
Read a single ` Frame ` value from the underlying stream . The function waits until it has retrieved enough data to parse a frame . Any data remaining in the read buffer after the frame has been parsed is kept there for the next call to ` read_frame ` .
pub async fn read_frame(&mut self) -> crate::Result<Option<Frame>> {
        loop {
            // Attempt to parse a frame from the buffered data. If enough data
            // has been buffered, the frame is returned.
            if let Some(frame) = self.parse_frame()? {
                return Ok(Some(frame));
            }
            // There is not enough buffered data to read a frame. Attempt to
            // read more data from the socket.
            //
            // On success, the number of bytes is returned. `0` indicates "end
            // of stream".
            if 0 == self.stream.read_buf(&mut self.buffer).await? {
                // The remote closed the connection. For this to be a clean
                // shutdown, there should be no data in the read buffer. If
                // there is, this means that the peer closed the socket while
                // sending a frame.
                if self.buffer.is_empty() {
                    return Ok(None);
                } else {
                    let s = "connection reset by peer".into();
                    return Err(s);
                }
            }
        }
    }
pub async fn read_frame ( & mut self ) -> crate :: Result < Option < Frame > > { loop { // Attempt to parse a frame from the buffered data. If enough data // has been buffered, the frame is returned. if let Some ( frame ) = self . parse_frame ( ) ? { return Ok ( Some ( frame ) ) ; } // There is not enough buffered data to read a frame. Attempt to // read more data from the socket. // // On success, the number of bytes is returned. `0` indicates "end // of stream". if 0 == self . stream . read_buf ( & mut self . buffer ) . await ? { // The remote closed the connection. For this to be a clean // shutdown, there should be no data in the read buffer. If // there is, this means that the peer closed the socket while // sending a frame. if self . buffer . is_empty ( ) { return Ok ( None ) ; } else { let s = " " . into ( ) ; return Err ( s ) ; } } } }
Read a single `Frame` value from the underlying stream.
Read a single ` Frame ` value from the underlying stream .
On success, the received frame is returned. If the `TcpStream`
is closed in a way that doesn't break a frame in half, it returns
`None`. Otherwise, an error is returned.
On success the received frame is returned . If the ` TcpStream ` is closed in a way that doesn ' t break a frame in half it returns ` None ` . Otherwise an error is returned .
&mut self