Skip to main content

workyard_state/store/
workspace.rs

1use super::Store;
2use crate::workspace::Workspace;
3use std::path::Path;
4use workyard_core::Problem;
5
6impl Store {
7	pub(crate) fn state_dir(&self) -> &Path {
8		&self.state
9	}
10
11	/// Open existing workspace state without creating or repairing any files.
12	pub fn open_existing(state: &Path, requested_root: Option<&Path>) -> Result<Self, Problem> {
13		let workspace = Workspace::open(state, requested_root)?;
14		Ok(Self {
15			root: workspace.root,
16			state: workspace.state,
17			workspace: workspace.gate,
18		})
19	}
20
21	/// Revalidate the workspace binding before relying on its state.
22	pub fn verify(&self) -> Result<(), Problem> {
23		Workspace::verify(&self.state, &self.root, &self.workspace)
24	}
25}