Serialize project to json
This commit is contained in:
parent
7a197d9b71
commit
d42fe2776c
|
@ -3677,9 +3677,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.137"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
|
@ -4113,6 +4113,8 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"png",
|
||||
"rfd",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"slint",
|
||||
"slint-build",
|
||||
"tiny-skia",
|
||||
|
|
|
@ -11,6 +11,8 @@ png = "0.17.16"
|
|||
rfd = "0.15.2"
|
||||
slint = "1.9.2"
|
||||
tiny-skia = "0.11.4"
|
||||
serde = {version = "1.0.140", features = ["derive"]}
|
||||
serde_json = "1.0"
|
||||
tool_helper = {path = "../tool_helper"}
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -95,7 +95,14 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
project.push(cur_job);
|
||||
}
|
||||
|
||||
Err(Error::from_text(format!("Adding {:?} jobs", project)))
|
||||
let string = match serde_json::to_string(&project) {
|
||||
Ok(string) => string,
|
||||
Err(error) => {
|
||||
return Err(Error::from_error(error));
|
||||
}
|
||||
};
|
||||
|
||||
Err(Error::from_text(format!("Adding {} jobs", string)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Job {
|
||||
name: String,
|
||||
file_path: PathBuf,
|
||||
|
@ -12,7 +13,7 @@ impl Job {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Project {
|
||||
jobs: Vec<Job>
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue