wtransport icon indicating copy to clipboard operation
wtransport copied to clipboard

Make receive_datagram return BytesMut

Open TheButlah opened this issue 1 month ago • 3 comments

Some use cases, such as using datagrams with serde via tokio_serde::Framed, require that messages received from the peer are BytesMut instead of Bytes. Currently, Connection::receive_datagram() returns a Datagram which itself can only give you Bytes, so the user of the API first needs to clone the data to get exclusive access to a buffer.

It would be nice if receive_datagrams instead returned a BytesMut, providing more performance for use cases like mine where I actually need exclusive access to the buffer.

TheButlah avatar May 05 '24 23:05 TheButlah