Mountain/RPC/CocoonService/Workspace/
OpenDocument.rs1#![allow(non_snake_case)]
2
3use serde_json::json;
6use tauri::Emitter;
7use tonic::{Response, Status};
8
9use crate::{
10 RPC::CocoonService::CocoonServiceImpl,
11 Vine::Generated::{OpenDocumentRequest, OpenDocumentResponse},
12 dev_log,
13};
14
15pub async fn Fn(
16 Service:&CocoonServiceImpl,
17 Request:OpenDocumentRequest,
18) -> Result<Response<OpenDocumentResponse>, Status> {
19 let URI = Request.uri.as_ref().map(|U| U.value.clone()).unwrap_or_default();
20 dev_log!("cocoon", "[CocoonService] open_document: {}", URI);
21
22 let _ = Service.environment.ApplicationHandle.emit(
23 "sky://editor/openDocument",
24 json!({ "uri": URI, "viewColumn": Request.view_column }),
25 );
26
27 Ok(Response::new(OpenDocumentResponse { success:true }))
28}