use crate::engine::action;
use crate::engine::state;
use crate::model::{Patch, PinAddress, Value};
#[derive(Debug)]
pub enum Request {
RemoveNode { node_id: String },
RemovePatch { patch: Patch },
SetValue {
node_id: String,
key: String,
value: Value,
},
}
impl From<Request> for action::Action {
fn from(request: Request) -> Self {
match request {
Request::RemoveNode { node_id } => Self::RemoveNode { node_id },
Request::RemovePatch { patch } => Self::RemovePatch {
patch: patch.into(),
},
Request::SetValue {
node_id,
key,
value,
} => Self::SetValue {
node_id,
key,
value: value.into(),
},
}
}
}
impl From<Patch> for state::Patch {
fn from(patch: Patch) -> Self {
Self::new(patch.source.into(), patch.destination.into())
}
}
impl From<PinAddress> for state::PinAddress {
fn from(pin_address: PinAddress) -> Self {
Self::new(pin_address.node_id, pin_address.pin_class)
}
}