From 5af7cc0cb1182a9a8d0648316010090bdf751b71 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 4 May 2024 12:53:34 +0200 Subject: [PATCH] fix backwards compatible rule fields --- petri/src/lib.rs | 2 ++ uscope/src/main.rs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/petri/src/lib.rs b/petri/src/lib.rs index 0eda324..73406ef 100644 --- a/petri/src/lib.rs +++ b/petri/src/lib.rs @@ -27,7 +27,9 @@ pub struct Rule { variants: Vec, pub enabled: bool, // probability: u8 + #[serde(alias = "flip_h")] pub flip_x: bool, + #[serde(alias = "flip_v")] pub flip_y: bool, pub rotate: bool, } diff --git a/uscope/src/main.rs b/uscope/src/main.rs index fd23e43..8daacb4 100644 --- a/uscope/src/main.rs +++ b/uscope/src/main.rs @@ -82,9 +82,10 @@ impl UScope { { let s = fs::read_to_string(path).ok()?; let data: Value = serde_json::from_str(&s).ok()?; - let cell_types = serde_json::from_value(data["cell_types"].clone()).ok()?; - let groups = serde_json::from_value(data["groups"].clone()).ok()?; - let rules = serde_json::from_value(data["rules"].clone()).ok()?; + // TODO: show errors to user + let cell_types = serde_json::from_value(data["cell_types"].clone()).unwrap(); + let groups = serde_json::from_value(data["groups"].clone()).unwrap(); + let rules = serde_json::from_value(data["rules"].clone()).unwrap(); self.cell_types = cell_types; self.dish.rules = rules; self.dish.cell_groups = groups;