forked from AeroRust/nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnss_type.rs
60 lines (56 loc) · 1.74 KB
/
gnss_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::count_tts;
use core::fmt;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
macro_rules! define_enum_with_count {
(
$(#[$outer:meta])*
enum $Name:ident { $(
$(#[$variant:meta])*
$Variant:ident
),* $(,)* }
) => {
$(#[$outer])*
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Debug, Hash, Eq, Clone, Copy)]
#[repr(u8)]
pub enum $Name {
$($Variant),*
}
impl $Name {
pub(crate) const COUNT: usize = count_tts!($($Variant),*);
pub const ALL_TYPES: [$Name; $Name::COUNT] = [
$($Name::$Variant),*
];
}
};
}
define_enum_with_count!(
/// Supported GNSS types
enum GnssType {
/// BeiDou Navigation Satellite System (BDS) from China.
Beidou,
/// European Global Navigation System (Galileo) from Europe.
Galileo,
/// Global Positioning System (GPS) from the United States.
Gps,
/// Globalnaya Navigazionnaya Sputnikovaya Sistema (GLONASS) from Russia.
Glonass,
/// Navigation Indian Constellation (NavIC) from India.
NavIC,
/// Quasi-Zenith Satellite System (QZSS) from Japan.
Qzss,
}
);
impl fmt::Display for GnssType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
GnssType::Beidou => write!(f, "Beidou"),
GnssType::Galileo => write!(f, "Galileo"),
GnssType::Gps => write!(f, "GPS"),
GnssType::Glonass => write!(f, "GLONASS"),
GnssType::NavIC => write!(f, "NavIC"),
GnssType::Qzss => write!(f, "QZSS"),
}
}
}