pub async fn send<W: AsyncWrite + Unpin, B: Buf>(
    stream: &mut W,
    message: &mut B,
    cipher: &Cipher
) -> Result<(), PacketError>
Available on crate feature encryption only.
Expand description

Send 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 or WriteHalf.
  • message - The message to send.
  • cipher - The cipher returned from server_start or client_start.

§Example

use tcp_handler::protocols::encrypt::send;

let mut writer = BytesMut::new().writer();
writer.write_string("hello server.")?;
send(&mut client, &mut writer.into_inner(), &cipher).await?;