use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RuntimePatch {
ReplaceView {
node_id: u64,
new_view: serde_json::Value,
},
UpdateState {
node_id: u64,
field: String,
value: serde_json::Value,
},
Batch(Vec<RuntimePatch>),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(dead_code)]
pub struct RuntimeStateSnapshot {
pub nodes: Vec<NodeStateSnapshot>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(dead_code)]
pub struct NodeStateSnapshot {
pub id: u64,
pub state: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(dead_code)]
pub struct RuntimeEvent {
pub kind: String,
pub payload: serde_json::Value,
}
pub fn apply_patch(patch: RuntimePatch) {
match patch {
RuntimePatch::ReplaceView { node_id: _, new_view: _ } => {
println!("Runtime: ReplaceView patch received.");
}
RuntimePatch::UpdateState { node_id: _, field: _, value: _ } => {
println!("Runtime: UpdateState patch received.");
}
RuntimePatch::Batch(patches) => {
for p in patches {
apply_patch(p);
}
}
}
}
pub fn snapshot_state() -> RuntimeStateSnapshot {
RuntimeStateSnapshot { nodes: Vec::new() }
}