jpreprocess_window/
structures.rs

1#[derive(PartialEq, Debug)]
2pub enum Quintuple<T> {
3    /// None, Some(T), None, None, None
4    Single(T),
5    /// None, Some(T), Some(T), None, None
6    Double(T, T),
7    /// None, Some(T), Some(T), Some(T), None
8    Triple(T, T, T),
9    /// None, Some(T), Some(T), Some(T), Some(T)
10    First(T, T, T, T),
11    /// Some(T), Some(T), Some(T), Some(T), Some(T)
12    Full(T, T, T, T, T),
13    /// Some(T), Some(T), Some(T), Some(T), None
14    ThreeLeft(T, T, T, T),
15    /// Some(T), Some(T), Some(T), None, None
16    TwoLeft(T, T, T),
17    /// Some(T), Some(T), None, None, None
18    Last(T, T),
19}
20
21#[derive(PartialEq, Debug)]
22pub enum Triple<T> {
23    /// None, Some(T), None
24    Single(T),
25    /// None, Some(T), Some(T)
26    First(T, T),
27    /// Some(T), Some(T), Some(T)
28    Full(T, T, T),
29    /// Some(T), Some(T), None
30    Last(T, T),
31}
32
33impl<T> From<Quintuple<T>> for Triple<T> {
34    fn from(value: Quintuple<T>) -> Self {
35        match value {
36            Quintuple::Single(c) => Self::Single(c),
37            Quintuple::Double(c, nx1) => Self::First(c, nx1),
38            Quintuple::Triple(c, nx1, _nx2) => Self::First(c, nx1),
39            Quintuple::First(c, nx1, _nx2, _nx3) => Self::First(c, nx1),
40            Quintuple::Full(p, c, nx1, _nx2, _nx3) => Self::Full(p, c, nx1),
41            Quintuple::ThreeLeft(p, c, nx1, _nx2) => Self::Full(p, c, nx1),
42            Quintuple::TwoLeft(p, c, nx1) => Self::Full(p, c, nx1),
43            Quintuple::Last(p, c) => Self::Last(p, c),
44        }
45    }
46}
47
48#[derive(PartialEq, Debug)]
49pub enum Double<T> {
50    /// None, Some(T)
51    First(T),
52    /// Some(T), Some(T)
53    Full(T, T),
54}
55
56impl<T> From<Quintuple<T>> for Double<T> {
57    fn from(value: Quintuple<T>) -> Self {
58        match value {
59            Quintuple::Single(c) => Self::First(c),
60            Quintuple::Double(c, _nx1) => Self::First(c),
61            Quintuple::Triple(c, _nx1, _nx2) => Self::First(c),
62            Quintuple::First(c, _nx1, _nx2, _nx3) => Self::First(c),
63            Quintuple::Full(p, c, _nx1, _nx2, _nx3) => Self::Full(p, c),
64            Quintuple::ThreeLeft(p, c, _nx1, _nx2) => Self::Full(p, c),
65            Quintuple::TwoLeft(p, c, _nx1) => Self::Full(p, c),
66            Quintuple::Last(p, c) => Self::Full(p, c),
67        }
68    }
69}
70
71#[derive(PartialEq, Debug)]
72pub enum QuadForward<T> {
73    /// Some(T), None, None, None
74    Single(T),
75    /// Some(T), Some(T), None, None
76    Double(T, T),
77    /// Some(T), Some(T), Some(T), None
78    Triple(T, T, T),
79    /// Some(T), Some(T), Some(T), Some(T)
80    Full(T, T, T, T),
81}
82
83impl<T> From<Quintuple<T>> for QuadForward<T> {
84    fn from(value: Quintuple<T>) -> Self {
85        match value {
86            Quintuple::Single(c) => Self::Single(c),
87            Quintuple::Double(c, nx1) => Self::Double(c, nx1),
88            Quintuple::Triple(c, nx1, nx2) => Self::Triple(c, nx1, nx2),
89            Quintuple::First(c, nx1, nx2, nx3) => Self::Full(c, nx1, nx2, nx3),
90            Quintuple::Full(_p, c, nx1, nx2, nx3) => Self::Full(c, nx1, nx2, nx3),
91            Quintuple::ThreeLeft(_p, c, nx1, nx2) => Self::Triple(c, nx1, nx2),
92            Quintuple::TwoLeft(_p, c, nx1) => Self::Double(c, nx1),
93            Quintuple::Last(_p, c) => Self::Single(c),
94        }
95    }
96}