Skip to main content

Mountain/IPC/WindServiceHandlers/Storage/
StorageKeys.rs

1//! Return every key in global storage as a JSON array. Used by
2//! Wind's storage-debug surfaces and by extensions iterating
3//! the global storage namespace.
4
5use std::sync::Arc;
6
7use CommonLibrary::Storage::StorageProvider::StorageProvider;
8use serde_json::{Value, json};
9
10use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
11
12pub async fn Fn(RunTime:Arc<ApplicationRunTime>) -> Result<Value, String> {
13	let Storage = RunTime
14		.Environment
15		.GetAllStorage(true)
16		.await
17		.map_err(|Error| format!("storage:keys failed: {}", Error))?;
18
19	let Keys:Vec<String> = Storage.as_object().map(|O| O.keys().cloned().collect()).unwrap_or_default();
20
21	Ok(json!(Keys))
22}