Mountain/RPC/CocoonService/Terminal/
CloseTerminal.rs1
2use tonic::{Response, Status};
5use CommonLibrary::Terminal::TerminalProvider::TerminalProvider;
6
7use crate::{
8 RPC::CocoonService::CocoonServiceImpl,
9 Vine::Generated::{CloseTerminalRequest, Empty},
10 dev_log,
11};
12
13pub async fn Fn(Service:&CocoonServiceImpl, Request:CloseTerminalRequest) -> Result<Response<Empty>, Status> {
14 let TerminalIdentifier = Request.terminal_id as u64;
15
16 dev_log!("cocoon", "[CocoonService] close_terminal: id={}", TerminalIdentifier);
17
18 match Service.environment.DisposeTerminal(TerminalIdentifier).await {
19 Ok(()) => Ok(Response::new(Empty {})),
20
21 Err(Error) => {
22 dev_log!(
23 "cocoon",
24 "warn: [CocoonService] close_terminal failed id={}: {}",
25 TerminalIdentifier,
26 Error
27 );
28
29 Err(Status::internal(format!("close_terminal: {}", Error)))
30 },
31 }
32}