Wrap `std::io::Read` into `futures::AsyncRead`

⚓ Rust    📅 2025-12-12    👤 surdeus    👁️ 1      

surdeus

Hello everyone, I'm trying to wrap R: Read into AsyncReader<R>: futures_io::AsyncRead.

I now recognized what a bad idea it is ...

My final code if you want to have a look (so many lines) (click for more details)

There must be many bugs in my code, such as leaving some wakers never waken...

I do this since I just want to avoid tokio::fs::File, and maybe I want to try other reactors in the future.

And I just burn out to also wrap W: Write into AsyncWriter<W>: futures_io::AsyncWrite.


Maybe interacting with the OS is the correct way.

I must stop myself from wasting time, and I highly suspect that I'm in the wrong way.

I wonder:

  1. why my attempt is so painful? Whether it's things like AsFd should be used instead...
  2. any crates can do this wrapping (for futures_io)?
  3. is it true that I have to implement a simple reactor to avoid losing wakers?

Thanks a loooooooooooooooot! :folded_hands:

1 post - 1 participant

Read full topic

🏷️ Rust_feed