xemwebe / yahoo_finance_api

Simple wrapper to yahoo! finance API to retrieve latest quotes and end-of-day quote histories
Apache License 2.0
69 stars 35 forks source link

thoughts on using [request](https://crates.io/crates/reqwest) #37

Closed 0xJepsen closed 9 months ago

0xJepsen commented 9 months ago

would you be open to using the request crate to allow for the http library to not bubble everything up to be async?

then you can do things like

        let resp = reqwest::blocking::get(url);
xemwebe commented 9 months ago

I am not sure, if I understand correctly what you are suggesting... if you use the blocking feature, you cN already avoid the use of async in your code.

0xJepsen commented 9 months ago

Let me try to explain a little better. Right now if i use this API, the async propagates up which makes everything that calls it async. Some people have called this a "red function" as described here. If instead on the send here https://github.com/xemwebe/yahoo_finance_api/blob/7652601c6dc079cdc685348a5ff0cb56303d094f/src/async_impl.rs#L80-L87 you used the request crate your function can be blue and not propagate the async

then you can do things like

        let resp = reqwest::blocking::get(url);

Would you be open to this change? If so I would maybe be interested in working on it

0xJepsen commented 9 months ago

After taking a closer look, i see you already support this with the blocking feature! Amazing