write_packet

Function write_packet 

pub async fn write_packet<W: AsyncWrite + Unpin>(
    buf: &mut Vec<u8>,
    writer: &mut W,
    packet: &Packet<'_>,
) -> Result<(), Error>
Expand description

Encodes packet into buf (clearing and reusing it), writes it to writer, then flushes.

buf is a caller-owned scratch buffer that is resized as needed. Reusing it across calls avoids a heap allocation per packet.