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