CommonLibrary/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}