Load the manifest, or an empty one when the file is absent.
(path: &Path)
| 21 | impl Manifest { |
| 22 | /// Load the manifest, or an empty one when the file is absent. |
| 23 | pub fn load(path: &Path) -> Result<Self> { |
| 24 | if !path.exists() { |
| 25 | return Ok(Self::default()); |
| 26 | } |
| 27 | let text = std::fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; |
| 28 | serde_json::from_str(&text).with_context(|| format!("parsing {}", path.display())) |
| 29 | } |
| 30 | |
| 31 | /// Write the manifest back as pretty JSON with a trailing newline. |
| 32 | fn save(&self, path: &Path) -> Result<()> { |