DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Terminal/TerminalDispose.rs
1//! Close a PTY, kill its child, and drop the entry from the
2//! provider's terminal registry. Idempotent - disposing an
3//! already-disposed id surfaces as a logged warning, not an
4//! error.
5
6use std::sync::Arc;
7
8use CommonLibrary::Terminal::TerminalProvider::TerminalProvider;
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 TerminalId = Arguments
15 .first()
16 .and_then(|V| V.as_u64())
17 .ok_or_else(|| "terminal:dispose requires terminal_id as first argument".to_string())?;
18
19 RunTime
20 .Environment
21 .DisposeTerminal(TerminalId)
22 .await
23 .map(|()| Value::Null)
24 .map_err(|Error| format!("terminal:dispose failed: {}", Error))
25}