pub async fn send_buffer(&mut self, mut buffer: SenderBuffer<T>) -> StrResult {
        buffer.inner[2..6].copy_from_slice(&self.next_packet_index.to_be_bytes());
        self.next_packet_index += 1;

        match &self.socket {
            StreamSendSocket::Udp(socket) => trace_err!(
                socket
                    .inner
                    .lock()
                    .await
                    .send((buffer.inner.freeze(), socket.peer_addr))
                    .await
            ),
            StreamSendSocket::Tcp(socket) => {
                trace_err!(socket.lock().await.send(buffer.inner.freeze()).await)
            }
            StreamSendSocket::ThrottledUdp(socket) => {
                trace_err!(socket.send(buffer.inner.freeze()).await)
            }
        }
    }
// The buffer is moved into the method. There is no way of reusing the same buffer twice without
// extra copies/allocations
The buffer is moved into the method. There is no way of reusing the same buffer twice without
extra copies/allocations
The buffer is moved into the method . There is no way of reusing the same buffer twice without extra copies / allocations
pub async fn send_buffer(&mut self, mut buffer: SenderBuffer<T>) -> StrResult {
        buffer.inner[2..6].copy_from_slice(&self.next_packet_index.to_be_bytes());
        self.next_packet_index += 1;
        match &self.socket {
            StreamSendSocket::Udp(socket) => trace_err!(
                socket
                    .inner
                    .lock()
                    .await
                    .send((buffer.inner.freeze(), socket.peer_addr))
                    .await
            ),
            StreamSendSocket::Tcp(socket) => {
                trace_err!(socket.lock().await.send(buffer.inner.freeze()).await)
            }
            StreamSendSocket::ThrottledUdp(socket) => {
                trace_err!(socket.send(buffer.inner.freeze()).await)
            }
        }
    }
pub async fn send_buffer ( & mut self , mut buffer : SenderBuffer < T > ) -> StrResult { buffer . inner [ 2 .. 6 ] . copy_from_slice ( & self . next_packet_index . to_be_bytes ( ) ) ; self . next_packet_index += 1 ; match & self . socket { StreamSendSocket :: Udp ( socket ) => trace_err ! ( socket inner lock ( ) await send ( ( buffer inner freeze ( ) socket peer_addr ) ) await ) , StreamSendSocket :: Tcp ( socket ) => { trace_err ! ( socket lock ( ) await send ( buffer inner freeze ( ) ) await ) } StreamSendSocket :: ThrottledUdp ( socket ) => { trace_err ! ( socket send ( buffer inner freeze ( ) ) await ) } } }
The buffer is moved into the method.
The buffer is moved into the method .
&mut self
buffer
SenderBuffer<T>