implStream不能取消固定

我正在尝试使用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 {
      // ...
  }
}

以上是implStream不能取消固定的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>