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