Skip to main content

Mountain/IPC/WindServiceHandlers/Utilities/RecentlyOpened/
Read.rs

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