huskies: merge 858
This commit is contained in:
@@ -3,6 +3,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Mutex;
|
||||
use tokio::sync::watch;
|
||||
|
||||
/// Global server session state: the open project root and a cancellation signal.
|
||||
pub struct SessionState {
|
||||
pub project_root: Mutex<Option<PathBuf>>,
|
||||
pub cancel_tx: watch::Sender<bool>,
|
||||
@@ -21,6 +22,7 @@ impl Default for SessionState {
|
||||
}
|
||||
|
||||
impl SessionState {
|
||||
/// Return the currently open project root, or an error if no project is open.
|
||||
pub fn get_project_root(&self) -> Result<PathBuf, String> {
|
||||
let root_guard = self.project_root.lock().map_err(|e| e.to_string())?;
|
||||
let root = root_guard.as_ref().ok_or_else(|| {
|
||||
|
||||
Reference in New Issue
Block a user