Function send

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

Send the message in tcp-handler compress 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.

§Example

use tcp_handler::protocols::compress::send;

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