pub async fn recv<R: AsyncRead + Unpin>(
stream: &mut R,
cipher: &Cipher,
) -> Result<BytesMut, PacketError>
Available on crate feature
encryption
only.Expand description
Recv the message in tcp-handler encrypt protocol.
§Runtime
Due to call block_in_place
internally,
this function cannot be called in a current_thread
runtime.
§Arguments
stream
- The tcp stream orReadHalf
.cipher
- The cipher returned fromserver_start
orclient_start
.
§Example
use tcp_handler::protocols::encrypt::recv;
let mut reader = recv(&mut server, &cipher).await?.reader();
let message = reader.read_string()?;