Mountain/IPC/WindServiceHandlers/Utilities/RecentlyOpened/Read.rs
1
2//! Reads and parses RecentlyOpened.json. Degrades to empty envelope on error.
3
4use serde_json::{Value, json};
5
6pub fn Fn() -> Result<Value, String> {
7 let Path = super::Path::Fn();
8
9 match std::fs::read_to_string(&Path) {
10 Ok(Contents) => {
11 match serde_json::from_str::<Value>(&Contents) {
12 Ok(Parsed) => Ok(Parsed),
13
14 Err(_) => Ok(json!({ "workspaces": [], "files": [] })),
15 }
16 },
17
18 Err(_) => Ok(json!({ "workspaces": [], "files": [] })),
19 }
20}