I'm trying to do this when implementing Stream:
let fut = (*crate::REQWEST).post(&uri)
.json(&self.query)
.send();
let res = futures::ready!(fut.poll_unpin(cx)).unwrap();
let json: Value = futures::ready!(res.json().poll_unpin(cx)).unwrap();
The futures::ready!
for res
works, but the second for json
keeps giving me trouble. If I use it as is (with poll_unpin
) it gives me this error:
error[E0277]: the trait bound `std::future::GenFuture<[static generator@DefId(126:732 ~ reqwest[1920]::async_impl[0]::response[0]::{{impl}}[
0]::json[0]::{{closure}}[0]) 0:reqwest::async_impl::response::Response {reqwest::async_impl::response::Response, reqwest::async_impl::respon
se::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]>: std::marker::Unpin` is not satisfied in `impl cor
e::future::future::Future`
--> src\queue.rs:195:57
|
195 | let res: Value = futures::ready!(res.json().poll_unpin(cx)).unwrap();
| ^^^^^^^^^^ within `impl core::future::future::Future`, the trait `std::marker:
:Unpin` is not implemented for `std::future::GenFuture<[static generator@DefId(126:732 ~ reqwest[1920]::async_impl[0]::response[0]::{{impl}}
[0]::json[0]::{{closure}}[0]) 0:reqwest::async_impl::response::Response {reqwest::async_impl::response::Response, reqwest::async_impl::respo
nse::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]>`
|
= help: the following implementations were found:
<std::future::GenFuture<T> as std::marker::Unpin>
= note: required because it appears within the type `impl core::future::future::Future`
= note: required because it appears within the type `impl core::future::future::Future`
which I took as meaning that the GenFuture
returned by json()
does not implement Unpin
, so I can't use it.
So I try just using pin()
instead and it gives me this error:
error[E0599]: no method named `poll` found for type `impl core::future::future::Future` in the current scope
--> src\queue.rs:195:57
|
195 | let res: Value = futures::ready!(res.json().poll(cx)).unwrap();
| ^^^^ method not found in `impl core::future::future::Future`
Not really sure what is happening at all. Any help with this would be appreciated...