Mountain/IPC/WindServiceHandlers/Model/ModelClose.rs
1#![allow(non_snake_case)]
2
3//! Close a text model. Drops the entry from
4//! `ApplicationState.Feature.Documents`. Idempotent - closing
5//! an already-closed URI is a no-op.
6
7use std::sync::Arc;
8
9use serde_json::Value;
10
11use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
12
13pub async fn ModelClose(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
14 let Uri = Arguments
15 .first()
16 .and_then(|V| V.as_str())
17 .ok_or("model:close requires uri".to_string())?;
18
19 RunTime.Environment.ApplicationState.Feature.Documents.Remove(Uri);
20 Ok(Value::Null)
21}