build: move the int/stream type mapping into a simdata module shared by the build script
This commit is contained in:
29
src/simdata.rs
Normal file
29
src/simdata.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#[derive(Debug)]
|
||||
pub enum StreamType {
|
||||
IMU,
|
||||
GPS,
|
||||
Annotations
|
||||
}
|
||||
|
||||
impl TryFrom<i8> for StreamType {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: i8) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
1 => Ok(StreamType::IMU),
|
||||
2 => Ok(StreamType::GPS),
|
||||
3 => Ok(StreamType::Annotations),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StreamType> for i8 {
|
||||
fn from(value: StreamType) -> Self {
|
||||
match value {
|
||||
StreamType::IMU => 1,
|
||||
StreamType::GPS => 2,
|
||||
StreamType::Annotations => 3
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user