Skip to main content

Mountain/RPC/CocoonService/Task/
ExecuteTask.rs

1//! Forward a task-execution request to Sky over the
2//! `sky://task/execute` channel.
3
4use serde_json::json;
5use tauri::Emitter;
6use tonic::{Response, Status};
7use ::Vine::Generated::{ExecuteTaskRequest, ExecuteTaskResponse};
8
9use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
10
11pub async fn Fn(
12	Service:&CocoonServiceImpl,
13
14	Request:ExecuteTaskRequest,
15) -> Result<Response<ExecuteTaskResponse>, Status> {
16	dev_log!(
17		"cocoon",
18		"[CocoonService] execute_task: name={} source={}",
19		Request.name,
20		Request.source
21	);
22
23	let _ = Service
24		.environment
25		.ApplicationHandle
26		.emit("sky://task/execute", json!({ "name": Request.name, "source": Request.source }));
27
28	Ok(Response::new(ExecuteTaskResponse { task_id:0, success:true }))
29}