diff options
| author | troido <troido@protonmail.com> | 2020-09-24 13:10:54 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-24 13:10:54 +0200 |
| commit | e6476e7afff0234d67ebce7c74e4c91c31d87755 (patch) | |
| tree | 638133c0f7c9253e863e01806150f8bec860d12e /src/persistence.rs | |
| parent | 523a635dc88bc7890a0e1d3c062a8165259761d6 (diff) | |
actually use the serde serialisation more
Diffstat (limited to 'src/persistence.rs')
| -rw-r--r-- | src/persistence.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/persistence.rs b/src/persistence.rs index 2d927ee..932840a 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -81,8 +81,7 @@ impl PersistentStorage for FileStorage { LoaderError::InvalidResource(Box::new(err)) } })?; - let json: Value = inv!(serde_json::from_str(&text))?; - let state = inv!(SaveState::from_json(&json))?; + let state = inv!(serde_json::from_str(&text))?; Ok(state) } @@ -129,7 +128,7 @@ impl PersistentStorage for FileStorage { fs::create_dir_all(&path)?; let fname = id.to_string() + ".save.json"; path.push(fname); - let text = state.to_json().to_string(); + let text = serde_json::to_string(&state).unwrap(); write_file_safe(path, text)?; Ok(()) } |
