-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathfix_type.rs
43 lines (41 loc) · 1.09 KB
/
fix_type.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/// Fix type
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum FixType {
Invalid,
Gps,
DGps,
/// Precise Position Service
Pps,
Rtk,
FloatRtk,
Estimated,
Manual,
Simulation,
}
impl FixType {
#[inline]
pub fn is_valid(self) -> bool {
match self {
FixType::Simulation | FixType::Manual | FixType::Estimated | FixType::Invalid => false,
FixType::DGps | FixType::Gps | FixType::Rtk | FixType::FloatRtk | FixType::Pps => true,
}
}
}
impl From<char> for FixType {
fn from(x: char) -> Self {
match x {
'0' => FixType::Invalid,
'1' => FixType::Gps,
'2' => FixType::DGps,
'3' => FixType::Pps,
'4' => FixType::Rtk,
'5' => FixType::FloatRtk,
'6' => FixType::Estimated,
'7' => FixType::Manual,
'8' => FixType::Simulation,
_ => FixType::Invalid,
}
}
}