Mountain/RPC/CocoonService/Debug/
StartDebugging.rs1
2use std::time::{SystemTime, UNIX_EPOCH};
6
7use serde_json::json;
8use tauri::Emitter;
9use tonic::{Response, Status};
10
11use crate::{
12 RPC::CocoonService::CocoonServiceImpl,
13 Vine::Generated::{StartDebuggingRequest, StartDebuggingResponse},
14 dev_log,
15};
16
17pub async fn Fn(
18 Service:&CocoonServiceImpl,
19
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}