Common/WorkSpace/RequestWorkSpaceTrust.rs
1//! # RequestWorkSpaceTrust Effect
2//!
3//! Defines the `ActionEffect` for prompting the user to trust the workspace.
4
5use std::sync::Arc;
6
7use serde_json::Value;
8
9use super::WorkSpaceProvider::WorkSpaceProvider;
10use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
11
12/// Creates an effect that, when executed, will prompt the user to grant or
13/// deny trust to the current workspace via a UI dialog.
14///
15/// It uses the `WorkSpaceProvider` capability from the environment, which in
16/// turn will likely use the `UserInterfaceProvider` to show the dialog.
17///
18/// # Parameters
19/// * `Options`: An optional `serde_json::Value` that can contain additional
20/// information or options for the trust prompt.
21///
22/// # Returns
23/// An `ActionEffect` that resolves with a `bool` indicating whether trust was
24/// granted.
25pub fn RequestWorkSpaceTrust(Options:Option<Value>) -> ActionEffect<Arc<dyn WorkSpaceProvider>, CommonError, bool> {
26 ActionEffect::New(Arc::new(move |Provider:Arc<dyn WorkSpaceProvider>| {
27 let OptionsClone = Options.clone();
28
29 Box::pin(async move { Provider.RequestWorkSpaceTrust(OptionsClone).await })
30 }))
31}