diff options
| author | troido <troido@protonmail.com> | 2020-09-25 08:54:20 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-25 08:54:20 +0200 |
| commit | 09306cb76c6e1eabb4082a985a0a0fa335bda5c1 (patch) | |
| tree | e43abd096374a8e79186b519d80372112ab0ca74 /src/persistence.rs | |
| parent | 9eb3a9da97e53cee14e585e027badb3783b8e25e (diff) | |
proper serialisation for playerstate; strum for old-style enums
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 932840a..446d93a 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -97,8 +97,7 @@ impl PersistentStorage for FileStorage { LoaderError::InvalidResource(Box::new(err)) } })?; - let json: Value = inv!(serde_json::from_str(&text))?; - let state = inv!(PlayerState::from_json(&json))?; + let state = inv!(serde_json::from_str(&text))?; Ok(state) } @@ -139,7 +138,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(()) } |
