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
19	Request:ExecuteTaskRequest,
20) -> Result<Response<ExecuteTaskResponse>, Status> {
21	dev_log!(
22		"cocoon",
23		"[CocoonService] execute_task: name={} source={}",
24		Request.name,
25		Request.source
26	);
27
28	let _ = Service
29		.environment
30		.ApplicationHandle
31		.emit("sky://task/execute", json!({ "name": Request.name, "source": Request.source }));
32
33	Ok(Response::new(ExecuteTaskResponse { task_id:0, success:true }))
34}