Generic solution to AsyncRead as std::io::Read
I just ran into this: https://crates.io/crates/async-stdio
It's only in an alpha release, I haven't scrutinized it, but if it's good, it's probably worth for tokio-tungstenite, async-tungstenite and potentially other (I thought tokio had the same issue somewhere) to re-use a generic solution to this problem rather than handrolling code for this in several places.
Yeah I like the idea and already saw that crate a few weeks ago. Once it's stable, I think we can move over to it. Back then I didn't see anything obviously wrong there.
One thing that might be a problem from our side is that we need to be able to have up to two wakers per read/write operation (reading a ping will cause a pong to be sent, so you can have a waker from your read and write task waiting for writing to be possible again). That will have to be investigated.
One thing that might be a problem from our side is that we need to be able to have up to two wakers per read/write operation
True, I forgot about that issue. That makes it quite specific and maybe not so easy to use a general solution. That really is a particular tungstenite quirk...
Needs someone to investigate in any case :)
Just wanted to mention that stjepang also released async-compat, but unfortunately it doesnt work for tokio 0.3 and it seems to always load tokio with the rt feature... also might not deal with the double waker issue.