Skip to main content

Mountain/RPC/CocoonService/Command/
UnregisterCommand.rs

1//! Remove a previously-registered Cocoon command from the executor.
2
3use CommonLibrary::Command::CommandExecutor::CommandExecutor;
4use tonic::{Response, Status};
5use ::Vine::Generated::{Empty, UnregisterCommandRequest};
6
7use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
8
9pub async fn Fn(Service:&CocoonServiceImpl, Request:UnregisterCommandRequest) -> Result<Response<Empty>, Status> {
10	dev_log!("cocoon", "[CocoonService] Unregistering command '{}'", Request.command_id);
11
12	if let Err(Error) = Service
13		.environment
14		.UnregisterCommand(String::new(), Request.command_id.clone())
15		.await
16	{
17		dev_log!(
18			"cocoon",
19			"warn: [CocoonService] Failed to unregister command '{}': {:?}",
20			Request.command_id,
21			Error
22		);
23	} else {
24		dev_log!("cocoon", "[CocoonService] Command removed: {}", Request.command_id);
25	}
26
27	Ok(Response::new(Empty {}))
28}