flowly_service/
pass.rs

1use std::marker::PhantomData;
2
3use flowly_core::Void;
4use futures::Stream;
5
6use crate::{Context, Service};
7
8#[derive(Debug, Clone, Copy)]
9pub struct Pass<I>(PhantomData<I>);
10
11impl<I: Send> Service<I> for Pass<I> {
12    type Out = Result<I, Void>;
13
14    #[inline]
15    fn handle(&mut self, input: I, _cx: &Context) -> impl Stream<Item = Self::Out> + Send {
16        futures::stream::once(async move { Ok(input) })
17    }
18}
19
20#[inline]
21pub fn flow<I>() -> Pass<I> {
22    Pass(PhantomData)
23}