Open Korvox opened 7 years ago
Actually, reqwest already have async but still in unstable... https://github.com/seanmonstar/reqwest/blob/master/tests/async.rs
Thats the point. Since v0.7 Reqwest has been based on async hyper but hides the async impl behind its sync layer. This pattern is useful for any library using hyper that wants to provide the same facade and could probably be crated up independently of reqwest and reused in a lot of crates.
Yes, I can see that they're still working on it. If they can provide something of roadmap, it will be better.
I had hoped to be able to make a separate crate, but quickly found that I wanted to be able to use private APIs, either with creating errors, building a client, building requests, using bodies... So it ended up in one crate.
I'm not against the idea, just providing the information for why it ended up in one crate for now.
Currently having a conversation over at inth-oauth2 about how to proceed in an async world. There are basically two arguments I see in the general use case:
Since reqwest already did the second option, and in a cursory glance a good 1/3 of all the code in reqwest right now is just in implementing the async facade for the default sync api, it would probably be a good idea to split out reusable functionality into its own crate as a library support helper for hyper libs that want to provide both async and sync versions of their api. Then everyone can still directly use hyper with their async "core" api, but provide a sync wrapper with all the channel / oneshot / thread / event loop boilerplate coming from hyper-sync-wrapper or whatever you would want to call it.