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