#[derive(Debug)]
pub struct FieldInfo {
pub field_def_num: u8,
pub name: &'static str,
pub type_name: &'static str,
pub array: Option<&'static str>,
pub scale: Option<f64>,
pub offset: Option<f64>,
pub units: Option<&'static str>,
pub components: &'static [Component],
pub sub_fields: &'static [SubField],
pub accumulate: bool,
}
#[derive(Debug)]
pub struct Component {
pub name: &'static str,
pub bits: u8,
pub scale: Option<f64>,
pub offset: Option<f64>,
pub units: Option<&'static str>,
pub accumulate: bool,
}
#[derive(Debug)]
pub struct SubField {
pub name: &'static str,
pub type_name: &'static str,
pub conditions: &'static [(&'static str, &'static str)],
pub components: &'static [Component],
pub scale: Option<f64>,
pub offset: Option<f64>,
pub units: Option<&'static str>,
}
#[derive(Debug)]
pub struct MesgInfo {
pub name: &'static str,
pub fields: &'static [FieldInfo],
}
impl MesgInfo {
pub fn field(&self, field_def_num: u8) -> Option<&FieldInfo> {
self.fields
.iter()
.find(|f| f.field_def_num == field_def_num)
}
pub fn field_by_name(&self, name: &str) -> Option<&FieldInfo> {
self.fields.iter().find(|f| f.name == name)
}
}