From 32740f3b22f5eaf06bb9c39a0c0c9d8c98d6dfbd Mon Sep 17 00:00:00 2001 From: Enrico Lumetti Date: Thu, 18 Mar 2021 21:21:48 +0100 Subject: [PATCH] Use serde_bare and update format version --- Cargo.toml | 1 - src/bin/{migrate.rs => stlt_migrate.rs} | 0 src/canvas.rs | 2 +- src/lib.rs | 6 +++--- src/main.rs | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) rename src/bin/{migrate.rs => stlt_migrate.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index 817de97..60cc5ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ features = ["v2_56"] version = "0.13.2" features = ["v3_22"] - [patch.crates-io] druid = { git = "https://github.com/doppioandante/druid", branch = "v0.7.0_stiletto", features = ["im", "svg"] } #druid = { path = "../druid/druid/", features = ["im", "svg"] } diff --git a/src/bin/migrate.rs b/src/bin/stlt_migrate.rs similarity index 100% rename from src/bin/migrate.rs rename to src/bin/stlt_migrate.rs diff --git a/src/canvas.rs b/src/canvas.rs index fc1e3e4..b33abe3 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -197,7 +197,7 @@ impl Serialize for Path { PathEl::MoveTo(pt) => Some(Into::<(f64, f64)>::into(pt)), PathEl::LineTo(pt) => Some(Into::<(f64, f64)>::into(pt)), _ => None, - })) + }).collect::>()) } } diff --git a/src/lib.rs b/src/lib.rs index 25ddcfb..0b239c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ pub mod commands { } pub const STILETTO_FORMAT_MAJOR: u16 = 0; -pub const STILETTO_FORMAT_MINOR: u16 = 1; +pub const STILETTO_FORMAT_MINOR: u16 = 2; #[derive(Serialize, Deserialize, Debug)] pub struct DocumentSnapshot { @@ -42,7 +42,7 @@ pub struct DocumentSnapshot { } impl DocumentSnapshot { - pub fn to_writer(&self, writer: W) -> Result<(), serde_json::Error> { - serde_json::to_writer_pretty(writer, &self) + pub fn to_writer(&self, writer: W) -> Result<(), serde_bare::Error> { + serde_bare::to_writer(writer, &self) } } diff --git a/src/main.rs b/src/main.rs index 3cefc60..8d2edf5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -274,8 +274,8 @@ impl AppDelegate for Delegate { } if let Some(file_info) = cmd.get(commands::OPEN_FILE) { if let Ok(f) = File::open(file_info.path()) { - let res_snapshot: Result = - serde_json::from_reader(f); + let res_snapshot: Result = + serde_bare::from_reader(f); if let Ok(document_snapshot) = res_snapshot { data.canvas.set_from_snapshot(document_snapshot); data.current_file_path = Some(file_info.path().to_path_buf());