You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+61-5Lines changed: 61 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,8 @@ use heapless::Vec;
66
66
externcrate alloc;
67
67
#[cfg(feature = "use_alloc")]
68
68
use alloc::vec::Vec;
69
+
use core::error::Error;
70
+
use core::fmt::{Display,Formatter};
69
71
#[cfg(feature = "location_event")]
70
72
use location_event::LocationEvent;
71
73
#[cfg(feature = "magnetometer_event")]
@@ -101,8 +103,7 @@ pub enum ProtocolParseError {
101
103
/// The message contained an event which is not known to the current implementation.
102
104
/// This can mean that:
103
105
/// * the message was malformed or
104
-
/// * that a newer protocol version has been used or
105
-
/// * that the event type has not been enabled as a feature.
106
+
/// * that a newer protocol version has been used.
106
107
UnknownEvent(Option<u8>),
107
108
/// The message contained an event which is known to the library but has not been selected as a feature and can thus not be parsed. Select the feature when compiling the library to handle this message.
ButtonParseError(_) => write!(f,"Error while parsing button event"),
130
+
InvalidLength(expected, actual) => write!(
131
+
f,
132
+
"Invalid message length: expected {} but received {}",
133
+
expected, actual
134
+
),
135
+
InvalidCrc(expected, actual) => write!(
136
+
f,
137
+
"Invalid CRC: expected {:#x} but calculated {:#x}",
138
+
expected, actual
139
+
),
140
+
InvalidFloatSize(length) => write!(
141
+
f,
142
+
"Failed to parse float from a message with size {}",
143
+
length
144
+
),
145
+
}
146
+
}
147
+
}
148
+
149
+
implErrorforProtocolParseError{
150
+
fnsource(&self) -> Option<&(dynError + 'static)>{
151
+
useProtocolParseError::*;
152
+
matchself{
153
+
ButtonParseError(e) => Some(e),
154
+
_ => None,
155
+
}
156
+
}
157
+
}
158
+
120
159
/// Lists all data packages which can be sent by the controller. Internal state used during parsing. Use [`ControllerEvent`] to return the actual event.
0 commit comments