Use serde_bare and update format version
This commit is contained in:
parent
6a2460c42f
commit
32740f3b22
|
|
@ -26,7 +26,6 @@ features = ["v2_56"]
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
features = ["v3_22"]
|
features = ["v3_22"]
|
||||||
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
druid = { git = "https://github.com/doppioandante/druid", branch = "v0.7.0_stiletto", features = ["im", "svg"] }
|
druid = { git = "https://github.com/doppioandante/druid", branch = "v0.7.0_stiletto", features = ["im", "svg"] }
|
||||||
#druid = { path = "../druid/druid/", features = ["im", "svg"] }
|
#druid = { path = "../druid/druid/", features = ["im", "svg"] }
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ impl Serialize for Path {
|
||||||
PathEl::MoveTo(pt) => Some(Into::<(f64, f64)>::into(pt)),
|
PathEl::MoveTo(pt) => Some(Into::<(f64, f64)>::into(pt)),
|
||||||
PathEl::LineTo(pt) => Some(Into::<(f64, f64)>::into(pt)),
|
PathEl::LineTo(pt) => Some(Into::<(f64, f64)>::into(pt)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}))
|
}).collect::<Vec<(f64, f64)>>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ pub mod commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const STILETTO_FORMAT_MAJOR: u16 = 0;
|
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)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct DocumentSnapshot {
|
pub struct DocumentSnapshot {
|
||||||
|
|
@ -42,7 +42,7 @@ pub struct DocumentSnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentSnapshot {
|
impl DocumentSnapshot {
|
||||||
pub fn to_writer<W: std::io::Write>(&self, writer: W) -> Result<(), serde_json::Error> {
|
pub fn to_writer<W: std::io::Write>(&self, writer: W) -> Result<(), serde_bare::Error> {
|
||||||
serde_json::to_writer_pretty(writer, &self)
|
serde_bare::to_writer(writer, &self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,8 @@ impl AppDelegate<StilettoState> for Delegate {
|
||||||
}
|
}
|
||||||
if let Some(file_info) = cmd.get(commands::OPEN_FILE) {
|
if let Some(file_info) = cmd.get(commands::OPEN_FILE) {
|
||||||
if let Ok(f) = File::open(file_info.path()) {
|
if let Ok(f) = File::open(file_info.path()) {
|
||||||
let res_snapshot: Result<DocumentSnapshot, serde_json::Error> =
|
let res_snapshot: Result<DocumentSnapshot, serde_bare::Error> =
|
||||||
serde_json::from_reader(f);
|
serde_bare::from_reader(f);
|
||||||
if let Ok(document_snapshot) = res_snapshot {
|
if let Ok(document_snapshot) = res_snapshot {
|
||||||
data.canvas.set_from_snapshot(document_snapshot);
|
data.canvas.set_from_snapshot(document_snapshot);
|
||||||
data.current_file_path = Some(file_info.path().to_path_buf());
|
data.current_file_path = Some(file_info.path().to_path_buf());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue