Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
WorkspacesGetFolders.rs

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