podo_core_driver/
symbol.rs

1use crate::unit::Unit;
2
3#[cfg(feature = "os")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
8pub struct Variable {
9    pub symbol: SymbolRaw,
10    pub unit: Option<Unit>,
11    pub fields: Vec<Field>,
12}
13
14#[derive(Clone, Debug, PartialEq, Eq, Hash)]
15#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
16pub struct Field {
17    pub name: String,
18    pub unit: Option<Unit>,
19}
20
21impl Variable {
22    pub fn full_symbol(&self) -> SymbolRaw {
23        let fields = self.fields.iter().map(|f| f.name.clone());
24        self.symbol.iter().cloned().chain(fields).collect()
25    }
26}
27
28pub type SymbolRef<'s> = &'s [String];
29pub type SymbolRaw = Vec<String>;