1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::unit::Unit;

#[cfg(feature = "os")]
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
pub struct Variable {
    pub symbol: SymbolRaw,
    pub unit: Option<Unit>,
    pub fields: Vec<Field>,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
pub struct Field {
    pub name: String,
    pub unit: Option<Unit>,
}

impl Variable {
    pub fn full_symbol(&self) -> SymbolRaw {
        let fields = self.fields.iter().map(|f| f.name.clone());
        self.symbol.iter().cloned().chain(fields).collect()
    }
}

pub type SymbolRef<'s> = &'s [String];
pub type SymbolRaw = Vec<String>;