Skip to main content

Mountain/IPC/WindServiceHandlers/Storage/
StorageDelete.rs

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