Skip to main content

Mountain/IPC/WindServiceHandlers/Extensions/
ExtensionsIsActive.rs

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