我正在尝试使用crates_io_api
. 我试图从流中获取数据,但我无法让它工作。
AsyncClient::all_crates
返回一个impl Stream
. 我如何从中获取数据?如果您提供代码会很有帮助。
我检查了异步书,但它没有用。谢谢你。
这是我当前的代码。
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 {
// ...
}
}