1use crate::{Connector, Pipe, ResetablePipe};
2use std::ops::Shr;
3
4pub struct Composed<P>
10where
11 P: Pipe,
12{
13 pipe: P,
14}
15
16impl<P> Composed<P>
17where
18 P: Pipe,
19{
20 pub fn new(pipe: P) -> Self {
22 Composed { pipe }
23 }
24
25 pub fn unwrap(self) -> P {
27 self.pipe
28 }
29}
30
31impl<P> Pipe for Composed<P>
32where
33 P: Pipe,
34{
35 type InputItem = P::InputItem;
36 type OutputItem = P::OutputItem;
37
38 fn next(&mut self, item: P::InputItem) -> P::OutputItem {
39 self.pipe.next(item)
40 }
41}
42
43impl<P: ResetablePipe> ResetablePipe for Composed<P>
44where
45 P: ResetablePipe,
46{
47 fn reset(&mut self) {
48 self.pipe.reset();
49 }
50}
51
52impl<P0, P1> Shr<P1> for Composed<P0>
53where
54 P0: Pipe,
55 P1: Pipe<InputItem = P0::OutputItem>,
56{
57 type Output = Composed<Connector<P0, P1>>;
58
59 fn shr(self, other: P1) -> Self::Output {
60 Self::Output::new(Connector::new(self.pipe, other))
61 }
62}