I have a reqwest::Response whose body I want to read into a buffer asynchronously inside a futures::executor::block_on, however the compiler complains about the following:
error[E0599]: the method `read` exists for struct `reqwest::Response`, but its trait bounds were not satisfied
--> src/get.rs:194:51
|
194 | let bytes_read = async { response.read(&mut buffer).await.map_err(Error::Read) };
| ^^^^ method cannot be called on `reqwest::Response` due to unsatisfied trait bounds
|
::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.10/src/async_impl/response.rs:26:1
|
26 | pub struct Response {
| -------------------
| |
| doesn't satisfy `reqwest::Response: futures::AsyncReadExt`
| doesn't satisfy `reqwest::Response: futures::AsyncRead`
|
= note: the following trait bounds were not satisfied:
`reqwest::Response: futures::AsyncRead`
which is required by `reqwest::Response: futures::AsyncReadExt`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `async-fetcher` due to previous error
Neither converting it to a string or bytes seem to help in this case.
Original code here, although I am trying to use reqwest for the network operations instead of isahc.
You probably shouldn't be using the futures::AsyncRead trait in the first place. You probably also shouldn't be using futures::executor::block_on, as reqwest requires use of a Tokio runtime.
Did you try using the reqwest::blocking module instead of the async api? That is a lot easier than trying to use reqwest via block_on.
I was mostly leaving the code as-is since the original plan was to have reqwest as an optional feature, though I think I will ditch that idea since the fork would be mostly for personal use.