Mountain/IPC/WindServiceHandlers/UI/WorkspacesGetName.rs
1//! Wire method: `workspaces:getName`.
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 Name = RunTime
11 .Environment
12 .ApplicationState
13 .Workspace
14 .GetWorkspaceFolders()
15 .into_iter()
16 .next()
17 .map(|F| F.GetDisplayName());
18
19 Ok(Name.map(|N| json!(N)).unwrap_or(Value::Null))
20}