Skip to main content

Mountain/IPC/WindServiceHandlers/Storage/
StorageDelete.rs

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