I was downloading some image data using reqwest:
let resp = reqwest::blocking::get(url).unwrap();
let mut picture = Picture::read_from(resp).unwrap();
Picture::read_from()
expects an std::io::Read
which reqwest::blocking::Response
implements.
Now something else was changed in the code and my reqwest::blocking::get()
no longer works (Cannot drop a runtime in a context where blocking is not allowed
).
So I'm converting my code from reqwest::blocking
to reqwest
.
The normal reqwest::Response
doesn't implement std::io::Read
, so I tried this instead:
let resp = reqwest::get(url).await.unwrap();
let mut picture = Picture::read_from(resp.bytes().await.unwrap()).unwrap();
But now I'm getting the trait std::io::Read is not implemented for bytes::bytes::Bytes
.
Do I need to wrap the Bytes
in a Cursor
or something or am I using reqwest
wrong?