Common/WorkSpace/IsWorkSpaceTrusted.rs
1//! # IsWorkSpaceTrusted Effect
2//!
3//! Defines the `ActionEffect` for checking if the current workspace is trusted.
4
5use std::sync::Arc;
6
7use super::WorkSpaceProvider::WorkSpaceProvider;
8use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
9
10/// Creates an effect that, when executed, will check if the current workspace
11/// is considered trusted by the user.
12///
13/// WorkSpace Trust is a security feature that restricts certain operations
14/// (like automatic task execution) in untrusted folders.
15///
16/// It uses the `WorkSpaceProvider` capability from the environment.
17///
18/// # Returns
19/// An `ActionEffect` that resolves with a `bool` indicating the trust state.
20pub fn IsWorkSpaceTrusted() -> ActionEffect<Arc<dyn WorkSpaceProvider>, CommonError, bool> {
21 ActionEffect::New(Arc::new(move |Provider:Arc<dyn WorkSpaceProvider>| {
22 Box::pin(async move { Provider.IsWorkSpaceTrusted().await })
23 }))
24}