pub(crate) async fn try_receive(&mut self) -> crate::Result<Option<()>> {
        self.packet.clear();

        // Read the packet header which contains the length and the sequence number
        // https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_packets.html
        // https://mariadb.com/kb/en/library/0-packet/#standard-packet
        let mut header = ret_if_none!(self.stream.peek(4).await?);
        self.packet_len = header.get_uint::<LittleEndian>(3)? as usize;
        self.next_seq_no = header.get_u8()?.wrapping_add(1);
        self.stream.consume(4);

        // Read the packet body and copy it into our internal buf
        // We must have a separate buffer around the stream as we can't operate directly
        // on bytes returned from the stream. We have various kinds of payload manipulation
        // that must be handled before decoding.
        let payload = ret_if_none!(self.stream.peek(self.packet_len).await?);
        self.packet.extend_from_slice(payload);
        self.stream.consume(self.packet_len);

        // TODO: Implement packet compression
        // TODO: Implement packet joining

        Ok(Some(()))
    }
/// Try to receive a packet from the database server. Returns `None` if the server has sent
/// no data.
Try to receive a packet from the database server. Returns `None` if the server has sent
no data.
Try to receive a packet from the database server . Returns ` None ` if the server has sent no data .
pub(crate) async fn try_receive(&mut self) -> crate::Result<Option<()>> {
        self.packet.clear();
        // Read the packet header which contains the length and the sequence number
        // https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_packets.html
        // https://mariadb.com/kb/en/library/0-packet/#standard-packet
        let mut header = ret_if_none!(self.stream.peek(4).await?);
        self.packet_len = header.get_uint::<LittleEndian>(3)? as usize;
        self.next_seq_no = header.get_u8()?.wrapping_add(1);
        self.stream.consume(4);
        // Read the packet body and copy it into our internal buf
        // We must have a separate buffer around the stream as we can't operate directly
        // on bytes returned from the stream. We have various kinds of payload manipulation
        // that must be handled before decoding.
        let payload = ret_if_none!(self.stream.peek(self.packet_len).await?);
        self.packet.extend_from_slice(payload);
        self.stream.consume(self.packet_len);
        // TODO: Implement packet compression
        // TODO: Implement packet joining
        Ok(Some(()))
    }
pub ( crate ) async fn try_receive ( & mut self ) -> crate :: Result < Option < ( ) > > { self . packet . clear ( ) ; // Read the packet header which contains the length and the sequence number // https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_packets.html // https://mariadb.com/kb/en/library/0-packet/#standard-packet let mut header = ret_if_none ! ( self stream peek ( 4 ) await ) ; self . packet_len = header . get_uint :: < LittleEndian > ( 3 ) ? as usize ; self . next_seq_no = header . get_u8 ( ) ? . wrapping_add ( 1 ) ; self . stream . consume ( 4 ) ; // Read the packet body and copy it into our internal buf // We must have a separate buffer around the stream as we can't operate directly // on bytes returned from the stream. We have various kinds of payload manipulation // that must be handled before decoding. let payload = ret_if_none ! ( self stream peek ( self packet_len ) await ) ; self . packet . extend_from_slice ( payload ) ; self . stream . consume ( self . packet_len ) ; // TODO: Implement packet compression // TODO: Implement packet joining Ok ( Some ( ( ) ) ) }
Try to receive a packet from the database server.
Try to receive a packet from the database server .
&mut self
&mut self