scryfall-rs
scryfall-rs copied to clipboard
Non-tokio runtime compatibility
Why?
Make scryfall-rs usable under non-tokio async runtimes. Reqwest is only compatible with tokio. Surf is compatible with async-std, tokio, or any other standard futures compliant runtime. https://github.com/seanmonstar/reqwest/issues/719#issuecomment-558758637
Known Issues
This will break backwards compatibility in the API. Specifically in regards to the removal of the ReqwestError variant.
It is not abstracted in HttpClientError as a string so going forward, any changes to the http client shouldn't have an impact on the public API.
Thanks for this PR, TIL about surf!
For my own learning, I'm curious about your motivation for this PR, I myself only use Tokio, tried async-std once but never really used, can you tell me some reasons for preferring async-std over Tokio?
@mendess The main motivation is to use this within a bevy app. It is not directly compatible with Tokio but uses it's own internal executor that is compatible with standard futures. Surf doesn't specifically rely on tokio or async-std but at least enables compatibility with either, in addition to any other executor that uses standard futures (such as in the case of bevy). I'm no expert in this but this is what I have concluded from my time boxed investigation.
We could also make a larger refactoring to the API and add a Client to it which could then support arbitrary ways to make the API calls (and change the current methods for the API calls to construct the client with Client::default for example). This would easily add support for re-using the HTTP client and ways to customize re-tries and throttling.
We could also make a larger refactoring to the API and add a
Clientto it which could then support arbitrary ways to make the API calls (and change the current methods for the API calls to construct the client withClient::defaultfor example). This would easily add support for re-using the HTTP client and ways to customize re-tries and throttling.
I really like this idea. This was my first real rust project so it naturally misses some good ideas haha. Feel free to make a PR with this change! And thanks for the idea!
I will see if I have the time and interest to work on it. No promises.