pub async fn read_packet<P: ProtocolPacket + Debug, R>(
stream: &mut R,
buffer: &mut BytesMut,
compression_threshold: Option<u32>,
cipher: &mut Option<Aes128CfbDec>,
) -> Result<P, Box<ReadPacketError>>
Expand description
Read a single packet from a stream.
The buffer is required because servers may send multiple packets in the same frame, so we need to store the packet data that’s left to read.
The current protocol state must be passed as a generic.
For the non-waiting version, see try_read_packet
.