use std::hash::{Hash, Hasher};
#[cfg(feature = "os")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug)]
#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
pub struct Unit {
pub name: String,
pub value: Option<Value>,
}
impl PartialEq for Unit {
fn eq(&self, other: &Self) -> bool {
self.name.eq(&other.name)
}
}
impl Eq for Unit {}
impl Hash for Unit {
fn hash<H: Hasher>(&self, state: &mut H) {
self.name.hash(state)
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "os", derive(Serialize, Deserialize))]
pub enum Value {
Real(f64),
Keyword(String),
}
impl Value {
pub fn is_real(&self) -> bool {
match &self {
Self::Real(_) => true,
Self::Keyword(_) => false,
}
}
pub fn is_keyword(&self) -> bool {
match &self {
Self::Real(_) => false,
Self::Keyword(_) => true,
}
}
}