Mountain/RPC/CocoonService/Window/
ShowProgress.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::{ShowProgressRequest, ShowProgressResponse},
15 dev_log,
16};
17
18pub async fn Fn(
19 Service:&CocoonServiceImpl,
20
21 Request:ShowProgressRequest,
22) -> Result<Response<ShowProgressResponse>, Status> {
23 dev_log!("cocoon", "[CocoonService] show_progress: title={}", Request.title);
24
25 let Handle = SystemTime::now()
26 .duration_since(UNIX_EPOCH)
27 .map(|D| D.as_millis() as u32)
28 .unwrap_or(0);
29
30 let _ = Service.environment.ApplicationHandle.emit(
31 "sky://progress/start",
32 json!({
33 "handle": Handle,
34 "title": Request.title,
35 "cancellable": Request.cancellable,
36 "location": Request.location,
37 }),
38 );
39
40 Ok(Response::new(ShowProgressResponse { handle:Handle }))
41}