1pub(crate) mod gga;
20pub(crate) mod gll;
21pub(crate) mod gns;
22pub(crate) mod gsa;
23pub(crate) mod gsv;
24pub(crate) mod rmc;
25pub(crate) mod vtg;
26pub(crate) mod alm;
27pub(crate) mod dtm;
28pub(crate) mod mss;
29pub(crate) mod stn;
30pub(crate) mod vbw;
31pub(crate) mod zda;
32pub(crate) mod dpt;
33pub(crate) mod dbs;
34pub(crate) mod mtw;
35pub(crate) mod vhw;
36pub(crate) mod hdt;
37pub(crate) mod mwv;
38
39use super::*;
40pub use gga::{GgaData, GgaQualityIndicator};
41pub use gll::GllData;
42pub use gns::GnsData;
43pub use gsa::{GsaData, GsaFixMode};
44pub use gsv::GsvData;
45pub use rmc::RmcData;
46use serde::Serialize;
47pub use vtg::VtgData;
48pub use alm::AlmData;
49pub use dtm::DtmData;
50pub use mss::MssData;
51pub use stn::StnData;
52pub use vbw::VbwData;
53pub use zda::ZdaData;
54pub use dpt::DptData;
55pub use dbs::DbsData;
56pub use mtw::MtwData;
57pub use vhw::VhwData;
58pub use hdt::HdtData;
59pub use mwv::MwvData;
60
61#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
65pub enum NavigationSystem {
66 Combination, Gps, Glonass, Galileo, Beidou, Navic, Qzss, Proprietary, Other,
92}
93
94impl core::fmt::Display for NavigationSystem {
95 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
96 match self {
97 NavigationSystem::Combination => write!(f, "combination"),
98 NavigationSystem::Gps => write!(f, "GPS"),
99 NavigationSystem::Glonass => write!(f, "GLONASS"),
100 NavigationSystem::Galileo => write!(f, "Galileo"),
101 NavigationSystem::Beidou => write!(f, "BeiDou"),
102 NavigationSystem::Navic => write!(f, "Navic"),
103 NavigationSystem::Qzss => write!(f, "QZSS"),
104 NavigationSystem::Proprietary => write!(f, "proprietary"),
105 NavigationSystem::Other => write!(f, "other"),
106 }
107 }
108}
109
110impl core::str::FromStr for NavigationSystem {
111 type Err = ParseError;
112
113 fn from_str(talker_id: &str) -> Result<Self, Self::Err> {
114 if talker_id.is_empty() {
115 return Err(ParseError::InvalidSentence(
116 "Invalid talker identifier".to_string(),
117 ));
118 }
119 if &talker_id[0..1] == "P" {
120 Ok(Self::Proprietary)
121 } else {
122 if talker_id.len() < 2 {
123 return Err(ParseError::InvalidSentence(
124 "Invalid talker identifier".to_string(),
125 ));
126 }
127 match &talker_id[0..2] {
128 "GN" => Ok(Self::Combination),
129 "GP" => Ok(Self::Gps),
130 "GL" => Ok(Self::Glonass),
131 "GA" => Ok(Self::Galileo),
132 "BD" => Ok(Self::Beidou),
133 "GI" => Ok(Self::Navic),
134 "QZ" => Ok(Self::Qzss),
135 _ => Ok(Self::Other),
136 }
137 }
138 }
139}
140
141#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
144pub enum FaaMode {
145 Autonomous,
147
148 Differential,
150
151 Estimated,
153
154 NotValid,
156
157 Simulator,
159}
160
161impl FaaMode {
162 pub fn new(val: &str) -> Result<FaaMode, String> {
163 match val {
164 "A" => Ok(FaaMode::Autonomous),
165 "D" => Ok(FaaMode::Differential),
166 "E" => Ok(FaaMode::Estimated),
167 "N" => Ok(FaaMode::NotValid),
168 _ => Err(format!("Unrecognized FAA information value: {}", val)),
169 }
170 }
171}
172
173impl core::fmt::Display for FaaMode {
174 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
175 match self {
176 FaaMode::Autonomous => write!(f, "A"),
177 FaaMode::Differential => write!(f, "D"),
178 FaaMode::Estimated => write!(f, "E"),
179 FaaMode::NotValid => write!(f, "N"),
180 _ => write!(f, "?"),
181 }
182 }
183}