use std::collections::HashMap;
use crate::engine::action;
#[derive(Clone, Debug)]
pub struct Node {
pub id: String,
pub class: String,
pub data: HashMap<String, Value>,
}
#[derive(Clone, Debug)]
pub enum Value {
String(String),
F32(f32),
Bool(bool),
}
impl Value {
pub fn unwrap_string(&self) -> &str {
if let Self::String(value) = self {
&value
} else {
panic!("The value is not of type String");
}
}
pub fn unwrap_f32(&self) -> f32 {
if let Self::F32(value) = self {
*value
} else {
panic!("The value is not of type F32");
}
}
pub fn unwrap_bool(&self) -> bool {
if let Self::Bool(value) = self {
*value
} else {
panic!("The value is not of type Bool");
}
}
}
impl Into<action::Value> for Value {
fn into(self) -> action::Value {
match self {
Self::Bool(value) => action::Value::Bool(value),
Self::F32(value) => action::Value::F32(value),
Self::String(value) => action::Value::String(value),
}
}
}
#[derive(Clone, Debug)]
pub struct Patch {
pub source: PinAddress,
pub destination: PinAddress,
}
#[derive(Clone, Debug)]
pub struct PinAddress {
pub node_id: String,
pub pin_class: String,
}