1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! Iroh blobs and tags client
use anyhow::Result;
use futures_util::{Stream, StreamExt};

pub mod blobs;
pub mod tags;

fn flatten<T, E1, E2>(
    s: impl Stream<Item = Result<Result<T, E1>, E2>>,
) -> impl Stream<Item = Result<T>>
where
    E1: std::error::Error + Send + Sync + 'static,
    E2: std::error::Error + Send + Sync + 'static,
{
    s.map(|res| match res {
        Ok(Ok(res)) => Ok(res),
        Ok(Err(err)) => Err(err.into()),
        Err(err) => Err(err.into()),
    })
}