Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
WorkspacesGetFolders.rs

1#![allow(unused_variables)]
2
3//! Wire method: `workspaces:getFolders`.
4
5use std::sync::Arc;
6
7use serde_json::{Value, json};
8
9use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
10
11pub async fn Fn(RunTime:Arc<ApplicationRunTime>) -> Result<Value, String> {
12	let Workspace = &RunTime.Environment.ApplicationState.Workspace;
13
14	let Folders = Workspace.GetWorkspaceFolders();
15
16	let FolderList:Vec<Value> = Folders
17		.iter()
18		.enumerate()
19		.map(|(Index, Folder)| {
20			json!({
21				"uri": Folder.URI.to_string(),
22				"name": Folder.Name,
23				"index": Index,
24			})
25		})
26		.collect();
27
28	Ok(json!(FolderList))
29}