No traits for tokio's UdpSocket but yes for tokio's TcpStream?

Tokio's TcpStream has the

pub fn into_split(self) -> (OwnedReadHalf, OwnedWriteHalf)

method which returns this tuple where each element implements AsyncWrite and AsyncRead. This way I can create an HTTP client that accepts things that implement AsyncWrite and AsyncRead.

I couldn't find any similar concept for UdpSocket. So, if I'm writing a library that uses tokio's UdpSocket then I cannot accept other implementations for UdpSocket because it's not a trait.

Is there something I'm missing? I'd like my client to use UdpSocket but also users could provide their own implementations of an async UdpSocket

For one it may help to look through the docs for the latest version :slight_smile:

You'll find that all methods that do network operations are async. The main type docs are better than anything I could put here

In particular this section may be helpful

It's true that there are no traits for datagrams.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.