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