embedded_sensors/ublox/
result.rs

1use core::fmt;
2
3pub type Result<T> = core::result::Result<T, Error>;
4
5#[derive(Debug)]
6pub enum Error {
7    NotEnoughData,
8    SerialError, // todo: impl serial error
9    ParserError(&'static str),
10}
11
12impl fmt::Display for Error {
13    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        use Error::*;
15
16        match &self {
17            NotEnoughData => write!(f, "Not enough data in buffer to parse nmea sentence."),
18            SerialError => write!(f, "A serial error occured."),
19            ParserError(e) => fmt::Display::fmt(&e, f),
20        }
21    }
22}