Looking for advice on going from AsyncRead/AsyncWrite -> datagrams

First I am relatively new to Rust and getting my head around its async paradigm is proving surprisingly difficult. So if there is a better/smarter way to do what I want to do I am all ears!

I have a library that expects an object that implements AsyncRead + AsyncWrite--it assumes some type of TCPStream. But I'd like to send it something that translates those writes/reads to/from framed send/read calls via a UdpSocket. Originally I thought that it shouldn't be a big deal since both tokio and async-stc have asynchronous UdpSocket implementations. But I can't figure out how to write the implementations to translate between the two and was hoping for some guidance or a better way to think about it.

My first question is if what I am doing makes sense ignoring the fact that trying to stream data over UDP is a bad idea because of lack of ordering and packet loss.

My second question is if anyone could point me in the right direction to some resources that might be able to help or provide a different way to approach the problem.

Can you give some details on how the udp messages you want to send are constructed from the tcp stream?

Have you looked at tokio_util::codec or tokio_util::udp?

I had looked at them a while ago but they don't seem to fully solve my problem because they UdpFramed is meant to wrap an AsyncRead/AsyncWrite similar to how this library I want to use does. I think maybe I just need to stop trying to use this library that requires an AsyncRead/AsyncWrite since apparently integrating these things is beyond my skill level in Rust right now.

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.