Skip to main content

Mountain/IPC/WindServiceHandlers/Storage/
StorageDelete.rs

1#![allow(non_snake_case)]
2
3//! Delete a key from global storage. The `true` first arg to
4//! `UpdateStorageValue` targets the global (cross-workspace)
5//! store; pairs with `StorageKeys` / `StorageGetItems` which
6//! also read from global.
7
8use std::sync::Arc;
9
10use CommonLibrary::Storage::StorageProvider::StorageProvider;
11use serde_json::Value;
12
13use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
14
15pub async fn StorageDelete(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
16	let Key = Arguments
17		.first()
18		.and_then(|V| V.as_str())
19		.ok_or("storage:delete requires key as first argument".to_string())?
20		.to_string();
21
22	RunTime
23		.Environment
24		.UpdateStorageValue(true, Key, None)
25		.await
26		.map_err(|Error| format!("storage:delete failed: {}", Error))?;
27
28	Ok(Value::Null)
29}