Mountain/IPC/WindServiceHandlers/Storage/
StorageGetItems.rs1#![allow(non_snake_case)]
2
3use std::sync::Arc;
10
11use CommonLibrary::{Environment::Requires::Requires, Storage::StorageProvider::StorageProvider};
12use serde_json::{Value, json};
13
14use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
15
16pub async fn StorageGetItems(RunTime:Arc<ApplicationRunTime>, _Arguments:Vec<Value>) -> Result<Value, String> {
17 let provider:Arc<dyn StorageProvider> = RunTime.Environment.Require();
18
19 match provider.GetAllStorage(true).await {
20 Ok(State) => {
21 if let Some(Obj) = State.as_object() {
22 let Tuples:Vec<Value> = Obj
23 .iter()
24 .map(|(K, V)| {
25 let ValStr = match V {
26 Value::String(S) => S.clone(),
27 _ => V.to_string(),
28 };
29 json!([K, ValStr])
30 })
31 .collect();
32 Ok(json!(Tuples))
33 } else {
34 Ok(json!([]))
35 }
36 },
37 Err(_) => Ok(json!([])),
38 }
39}