Mountain/RPC/CocoonService/Command/
RegisterCommand.rs1
2use CommonLibrary::Command::CommandExecutor::CommandExecutor;
6use tonic::{Response, Status};
7
8use crate::{
9 RPC::CocoonService::CocoonServiceImpl,
10 Vine::Generated::{Empty, RegisterCommandRequest},
11 dev_log,
12};
13
14pub async fn Fn(Service:&CocoonServiceImpl, Request:RegisterCommandRequest) -> Result<Response<Empty>, Status> {
15 dev_log!(
16 "cocoon",
17 "[CocoonService] Registering command '{}' from extension '{}'",
18 Request.command_id,
19 Request.extension_id
20 );
21
22 if let Err(Error) = Service
23 .environment
24 .RegisterCommand(Request.extension_id.clone(), Request.command_id.clone())
25 .await
26 {
27 dev_log!(
28 "cocoon",
29 "warn: [CocoonService] Failed to register command '{}': {:?}",
30 Request.command_id,
31 Error
32 );
33 } else {
34 dev_log!(
35 "cocoon",
36 "[CocoonService] Command registered: id={}, title={:?}",
37 Request.command_id,
38 Request.title
39 );
40 }
41
42 Ok(Response::new(Empty {}))
43}