use futures::{StreamExt, stream}; use isahc::AsyncReadResponseExt; use rss::Channel; pub async fn retrieve<'a, I>(urls: I) -> impl StreamExt where I : IntoIterator { stream::iter(urls) .flat_map(|url| stream::once(retrieve_one_or_warn(url))) .filter_map(async |result| result.ok()) } async fn retrieve_one_or_warn(url: &str) -> anyhow::Result { retrieve_one(url).await .inspect_err(|err| eprintln!("Failed to fetch {url}: {:#?}", err)) } async fn retrieve_one(url: &str) -> anyhow::Result { let content = isahc::get_async(url).await?.bytes().await?; Ok(Channel::read_from(&content[..])?) }