DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Extensions/ExtensionsIsActive.rs
1//! `extensions:isActive(id) -> bool` - predicate over the
2//! scanner's registry. Currently a "scanned & present" check;
3//! a future revision should consult Cocoon's per-extension
4//! activation table so the answer reflects whether the
5//! extension's `activate()` function actually ran.
6
7use std::sync::Arc;
8
9use CommonLibrary::ExtensionManagement::ExtensionManagementService::ExtensionManagementService;
10use serde_json::{Value, json};
11
12use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
13
14pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
15 let Id = Arguments
16 .first()
17 .and_then(|V| V.as_str())
18 .ok_or_else(|| "extensions:isActive requires string id as first argument".to_string())?
19 .to_string();
20
21 let Extension = RunTime
22 .Environment
23 .GetExtension(Id)
24 .await
25 .map_err(|Error| format!("extensions:isActive failed: {}", Error))?;
26
27 Ok(json!(Extension.is_some()))
28}