pub async fn flush(&mut self) -> Result<(), SendError> {
        if !self.out_packet.is_empty() {
            self.bandwidth_limiter.update_available();
            self.bandwidth_limiter.delay_until_available().await;

            poll_fn(|cx| self.outgoing_packets.poll_ready(cx))
                .await
                .map_err(|_| SendError::Disconnected)?;
            let out_packet = mem::replace(&mut self.out_packet, self.packet_pool.acquire());
            self.bandwidth_limiter.take_bytes(out_packet.len() as u32);
            self.outgoing_packets
                .start_send(out_packet)
                .map_err(|_| SendError::Disconnected)?;
        }

        Ok(())
    }
/// Finish sending any unsent coalesced packets.
///
/// This *must* be called to guarantee that any sent messages are actually sent to the outgoing
/// packet stream.
///
/// This method is cancel safe.
Finish sending any unsent coalesced packets.
This *must* be called to guarantee that any sent messages are actually sent to the outgoing
packet stream.

This method is cancel safe.
Finish sending any unsent coalesced packets . This * must * be called to guarantee that any sent messages are actually sent to the outgoing packet stream . This method is cancel safe .
pub async fn flush(&mut self) -> Result<(), SendError> {
        if !self.out_packet.is_empty() {
            self.bandwidth_limiter.update_available();
            self.bandwidth_limiter.delay_until_available().await;
            poll_fn(|cx| self.outgoing_packets.poll_ready(cx))
                .await
                .map_err(|_| SendError::Disconnected)?;
            let out_packet = mem::replace(&mut self.out_packet, self.packet_pool.acquire());
            self.bandwidth_limiter.take_bytes(out_packet.len() as u32);
            self.outgoing_packets
                .start_send(out_packet)
                .map_err(|_| SendError::Disconnected)?;
        }
        Ok(())
    }
pub async fn flush ( & mut self ) -> Result < ( ) , SendError > { if ! self . out_packet . is_empty ( ) { self . bandwidth_limiter . update_available ( ) ; self . bandwidth_limiter . delay_until_available ( ) . await ; poll_fn ( | cx | self . outgoing_packets . poll_ready ( cx ) ) . await . map_err ( | _ | SendError :: Disconnected ) ? ; let out_packet = mem :: replace ( & mut self . out_packet , self . packet_pool . acquire ( ) ) ; self . bandwidth_limiter . take_bytes ( out_packet . len ( ) as u32 ) ; self . outgoing_packets . start_send ( out_packet ) . map_err ( | _ | SendError :: Disconnected ) ? ; } Ok ( ( ) ) }
Finish sending any unsent coalesced packets.
Finish sending any unsent coalesced packets .
&mut self
&mut self