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