Common/WorkSpace/
GetWorkSpaceConfigurationPath.rs

1//! # GetWorkSpaceConfigurationPath Effect
2//!
3//! Defines the `ActionEffect` for retrieving the path to the workspace's
4//! configuration file.
5
6use std::{path::PathBuf, sync::Arc};
7
8use super::WorkSpaceProvider::WorkSpaceProvider;
9use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
10
11/// Creates an effect that, when executed, will retrieve the file path of the
12/// current workspace's configuration file (e.g., the `.code-workspace` file).
13///
14/// It uses the `WorkSpaceProvider` capability from the environment.
15///
16/// # Returns
17/// An `ActionEffect` that resolves with an `Option<PathBuf>`, containing the
18/// path if a workspace configuration file is open, or `None` otherwise.
19pub fn GetWorkSpaceConfigurationPath() -> ActionEffect<Arc<dyn WorkSpaceProvider>, CommonError, Option<PathBuf>> {
20	ActionEffect::New(Arc::new(move |Provider:Arc<dyn WorkSpaceProvider>| {
21		Box::pin(async move { Provider.GetWorkSpaceConfigurationPath().await })
22	}))
23}