pub async fn write_packet<W: AsyncWrite + Unpin>( writer: &mut W, packet: &Packet<'_>, ) -> Result<(), Error>
Encode and write a full MQTT packet to the writer, then flush.