Function tcp_handler::protocols::encrypt::send
source · 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 orWriteHalf
.message
- The message to send.cipher
- The cipher returned fromserver_start
orclient_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?;