Skip to main content

mzdata_spectrum/
utils.rs

1use std::cmp::Ordering;
2
3/// The different kinds of orientations ion mobility data may be present in.
4#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
5pub enum HasIonMobility {
6    /// No ion mobility measurement found
7    #[default]
8    None = 0,
9    /// A single ion mobility point measurement
10    Point = 1,
11    /// Multiple ion mobility point measurements along an axis
12    Dimension = 2
13}
14
15impl PartialOrd for HasIonMobility {
16    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
17        Some(self.cmp(other))
18    }
19}
20
21impl Ord for HasIonMobility {
22    fn cmp(&self, other: &Self) -> Ordering {
23        match self {
24            HasIonMobility::None => {
25                match other {
26                    HasIonMobility::None => Ordering::Equal,
27                    _ => Ordering::Less
28                }
29            },
30            HasIonMobility::Point => {
31                match other {
32                    HasIonMobility::None => Ordering::Greater,
33                    HasIonMobility::Point => Ordering::Equal,
34                    HasIonMobility::Dimension => Ordering::Less,
35                }
36            },
37            HasIonMobility::Dimension => {
38                match other {
39                    HasIonMobility::Dimension => Ordering::Equal,
40                    _ => Ordering::Greater
41                }
42            },
43        }
44    }
45}