iroh_node_util/rpc/client.rs
1//! Client to interact with iroh nodes and endpoints.
2use anyhow::Result;
3use futures_lite::{Stream, StreamExt};
4
5pub mod net;
6pub mod node;
7
8fn flatten<T, E1, E2>(
9 s: impl Stream<Item = Result<Result<T, E1>, E2>>,
10) -> impl Stream<Item = Result<T>>
11where
12 E1: std::error::Error + Send + Sync + 'static,
13 E2: std::error::Error + Send + Sync + 'static,
14{
15 s.map(|res| match res {
16 Ok(Ok(res)) => Ok(res),
17 Ok(Err(err)) => Err(err.into()),
18 Err(err) => Err(err.into()),
19 })
20}