Mountain/IPC/WindServiceHandlers/Model/ModelGetAll.rs
1#![allow(non_snake_case)]
2
3//! Bulk snapshot of every open text model. Used by Wind on
4//! workbench restore to repopulate the Monaco model registry
5//! without per-tab `ModelOpen` round-trips.
6
7use std::sync::Arc;
8
9use serde_json::{Value, json};
10
11use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
12
13pub async fn ModelGetAll(RunTime:Arc<ApplicationRunTime>) -> Result<Value, String> {
14 let All = RunTime
15 .Environment
16 .ApplicationState
17 .Feature
18 .Documents
19 .GetAll()
20 .into_iter()
21 .map(|(Uri, Document)| {
22 json!({
23 "uri": Uri,
24 "content": Document.Lines.join(&Document.EOL),
25 "version": Document.Version,
26 "languageId": Document.LanguageIdentifier,
27 })
28 })
29 .collect::<Vec<_>>();
30
31 Ok(Value::Array(All))
32}