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