Mountain/RPC/CocoonService/Terminal/
TerminalInput.rs1use tonic::{Response, Status};
4use CommonLibrary::Terminal::TerminalProvider::TerminalProvider;
5use ::Vine::Generated::{Empty, TerminalInputRequest};
6
7use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
8
9pub async fn Fn(Service:&CocoonServiceImpl, Request:TerminalInputRequest) -> Result<Response<Empty>, Status> {
10 let TerminalIdentifier = Request.terminal_id as u64;
11
12 dev_log!(
13 "cocoon",
14 "[CocoonService] terminal_input: id={} bytes={}",
15 TerminalIdentifier,
16 Request.data.len()
17 );
18
19 let Text = String::from_utf8_lossy(&Request.data).into_owned();
20
21 match Service.environment.SendTextToTerminal(TerminalIdentifier, Text).await {
22 Ok(()) => Ok(Response::new(Empty {})),
23
24 Err(Error) => {
25 dev_log!(
26 "cocoon",
27 "warn: [CocoonService] terminal_input failed id={}: {}",
28 TerminalIdentifier,
29 Error
30 );
31
32 Err(Status::not_found(format!("terminal_input: {}", Error)))
33 },
34 }
35}