xitca_service/pipeline/
struct.rs

1use core::{
2    fmt::{self, Debug, Display, Formatter},
3    marker::PhantomData,
4};
5
6/// A pipeline type where two fields have a parent-child/first-second relationship
7pub struct Pipeline<F, S, M = ()> {
8    pub first: F,
9    pub second: S,
10    _marker: PhantomData<M>,
11}
12
13impl<F, S, M> Pipeline<F, S, M> {
14    pub const fn new(first: F, second: S) -> Self {
15        Self {
16            first,
17            second,
18            _marker: PhantomData,
19        }
20    }
21}
22
23impl<F, S, M> Clone for Pipeline<F, S, M>
24where
25    F: Clone,
26    S: Clone,
27{
28    fn clone(&self) -> Self {
29        Self {
30            first: self.first.clone(),
31            second: self.second.clone(),
32            _marker: PhantomData,
33        }
34    }
35}
36
37impl<F, S, M> Debug for Pipeline<F, S, M>
38where
39    F: Debug,
40    S: Debug,
41{
42    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
43        f.debug_struct("Pipeline")
44            .field("first", &self.first)
45            .field("second", &self.second)
46            .finish()
47    }
48}
49
50impl<F, S, M> Display for Pipeline<F, S, M>
51where
52    F: Display,
53    S: Display,
54{
55    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
56        write!(f, "{}, {}", self.first, self.second)
57    }
58}