I'm trying to get data using crates_io_api
.
I attempted to get data from a stream, but
I can not get it to work.
AsyncClient::all_crates
returns an impl Stream
. How do I get data from it? It would be helpful if you provide code.
I checked out the async book but it didn't work. Thank you.
Here's my current code.
use crates_io_api::{AsyncClient, Error};
use futures::stream::StreamExt;
async fn get_all(query: Option<String>) -> Result<crates_io_api::Crate, Error> {
// Instantiate the client.
let client = AsyncClient::new(
"test (test@test.com)",
std::time::Duration::from_millis(10000),
)?;
let stream = client.all_crates(query);
// what should I do after?
// ERROR: `impl Stream cannot be unpinned`
while let Some(item) = stream.next().await {
// ...
}
}