Mountain/RPC/CocoonService/Debug/
StartDebugging.rs1#![allow(non_snake_case)]
2
3use std::time::{SystemTime, UNIX_EPOCH};
7
8use serde_json::json;
9use tauri::Emitter;
10use tonic::{Response, Status};
11
12use crate::{
13 RPC::CocoonService::CocoonServiceImpl,
14 Vine::Generated::{StartDebuggingRequest, StartDebuggingResponse},
15 dev_log,
16};
17
18pub async fn Fn(
19 Service:&CocoonServiceImpl,
20 Request:StartDebuggingRequest,
21) -> Result<Response<StartDebuggingResponse>, Status> {
22 dev_log!("cocoon", "[CocoonService] start_debugging: type={}", Request.debug_type);
23
24 let SessionIdentifier = format!(
25 "debug-{}",
26 SystemTime::now().duration_since(UNIX_EPOCH).map(|D| D.as_millis()).unwrap_or(0)
27 );
28
29 let _ = Service.environment.ApplicationHandle.emit(
30 "sky://debug/start",
31 json!({
32 "sessionId": SessionIdentifier,
33 "debugType": Request.debug_type,
34 "configuration": Request.configuration.as_ref().map(|C| json!({
35 "name": C.name,
36 "type": C.r#type,
37 "request": C.request,
38 })),
39 }),
40 );
41
42 Ok(Response::new(StartDebuggingResponse { success:true }))
43}