blob: 534bb77e7485c1ebefa2de6973f0a00de6f5b092 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
//! Functions to help working with onion services.
use crate::internal_prelude::*;
/// Consume a stream of [`RendRequest`], accepting them all, and produce a
/// stream of [`StreamRequest`].
///
/// If you want to reject certain [`RendRequest`]s, you can use
/// [`StreamExt::filter`](futures::StreamExt::filter) or
/// similar in order to remove them from the incoming stream.
pub fn handle_rend_requests<S>(rend_requests: S) -> impl Stream<Item = StreamRequest>
where
S: Stream<Item = RendRequest>,
{
rend_requests.flat_map_unordered(None, |rend_request| {
Box::pin(rend_request.accept())
.map(|outcome| match outcome {
Ok(stream_requests) => Either::Left(stream_requests),
Err(e) => {
warn_report!(e, "Problem while accepting rendezvous request");
Either::Right(futures::stream::empty())
}
})
.flatten_stream()
})
}
|