Skip to main content

varar_runner/
baseline_store.rs

1//! The filesystem `BaselineStore`: the committed drift baseline lives at the
2//! project root as `varar.lock.json`. The core owns the format; this only reads
3//! and writes the raw text.
4
5use std::path::{Path, PathBuf};
6use varar_core::drift::BaselineStore;
7
8pub struct FileBaselineStore {
9    path: PathBuf,
10}
11
12impl FileBaselineStore {
13    pub fn new(root: &Path) -> FileBaselineStore {
14        FileBaselineStore {
15            path: root.join("varar.lock.json"),
16        }
17    }
18}
19
20impl BaselineStore for FileBaselineStore {
21    fn read(&self) -> Option<String> {
22        std::fs::read_to_string(&self.path).ok()
23    }
24
25    fn write(&mut self, contents: &str) {
26        let _ = std::fs::write(&self.path, contents);
27    }
28}