Skip to main content

Mountain/RPC/CocoonService/Task/
ExecuteTask.rs

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