Compare commits

..

1 Commits

Author SHA1 Message Date
Enrico Lumetti e8e986f097 Implement basics for document migration 2021-03-18 01:59:30 +01:00
6 changed files with 8 additions and 7 deletions

View File

@ -26,6 +26,7 @@ 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"] }

View File

@ -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::<Vec<(f64, f64)>>())
}))
}
}

View File

@ -32,7 +32,7 @@ pub mod commands {
}
pub const STILETTO_FORMAT_MAJOR: u16 = 0;
pub const STILETTO_FORMAT_MINOR: u16 = 2;
pub const STILETTO_FORMAT_MINOR: u16 = 1;
#[derive(Serialize, Deserialize, Debug)]
pub struct DocumentSnapshot {
@ -42,7 +42,7 @@ pub struct DocumentSnapshot {
}
impl DocumentSnapshot {
pub fn to_writer<W: std::io::Write>(&self, writer: W) -> Result<(), serde_bare::Error> {
serde_bare::to_writer(writer, &self)
pub fn to_writer<W: std::io::Write>(&self, writer: W) -> Result<(), serde_json::Error> {
serde_json::to_writer_pretty(writer, &self)
}
}

View File

@ -274,8 +274,8 @@ impl AppDelegate<StilettoState> 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<DocumentSnapshot, serde_bare::Error> =
serde_bare::from_reader(f);
let res_snapshot: Result<DocumentSnapshot, serde_json::Error> =
serde_json::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());

View File

@ -47,7 +47,7 @@ impl StilettoDocument {
pub fn migrate_to_next(self) -> StilettoDocument {
match self {
StilettoDocument::DocumentSnapshot0_1(snapshot) => StilettoDocument::DocumentSnapshot0_2(snapshot) ,
StilettoDocument::DocumentSnapshot0_1(_) => self,
StilettoDocument::DocumentSnapshot0_2(_) => self,
}
}