Skip to main content

rpfm_ipc/
messages.rs

1//---------------------------------------------------------------------------//
2// Copyright (c) 2017-2026 Ismael Gutiérrez González. All rights reserved.
3//
4// This file is part of the Rusted PackFile Manager (RPFM) project,
5// which can be found here: https://github.com/Frodo45127/rpfm.
6//
7// This file is licensed under the MIT license, which can be found here:
8// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
9//---------------------------------------------------------------------------//
10
11//! # IPC Messages Module
12//!
13//! This module defines the core IPC protocol structures used for communication between the RPFM
14//! frontend and backend server.
15//!
16//! ## Overview
17//!
18//! The protocol is built around three main types:
19//!
20//! - [`Message<T>`]: A generic wrapper that adds request-response correlation via unique IDs.
21//! - [`Command`]: An enum defining all actions the frontend can request from the server.
22//! - [`Response`]: An enum defining all possible results the server can return.
23//!
24//! ## Message Correlation
25//!
26//! Every message includes a unique `id` field that allows the frontend to match responses to their
27//! original requests. This enables:
28//!
29//! - **Asynchronous communication**: Multiple requests can be in flight simultaneously.
30//! - **Non-blocking UI**: The frontend doesn't need to wait for responses before sending new requests.
31//! - **Error handling**: Responses can be matched back to the context that initiated them.
32//!
33//! ## Command Categories
34//!
35//! Commands are organized into logical groups:
36//!
37//! - **PackFile Operations**: Open, save, close, and modify PackFiles.
38//! - **PackedFile Operations**: Create, delete, extract, rename, and decode individual files.
39//! - **Dependency Operations**: Query and manage game dependencies.
40//! - **Search Operations**: Global search and reference lookups.
41//! - **Schema Operations**: Load, save, and update table schemas.
42//! - **Settings Operations**: Get and set application settings.
43//! - **Update Operations**: Check for and apply updates to schemas, translations, etc.
44//! - **Diagnostics**: Run diagnostic checks on PackFiles.
45//! - **Navigation**: Go-to-definition and reference search features.
46//!
47//! ## Response Types
48//!
49//! Responses are typically named after the types they contain (e.g., `Response::Bool(bool)`,
50//! `Response::String(String)`). For complex operations, specialized responses like
51//! `Response::DBRFileInfo` or `Response::ContainerInfoVecRFileInfo` carry domain-specific data.
52//!
53//! Each [`Command`] variant's documentation specifies which [`Response`] variant(s) it returns.
54
55use serde::{Serialize, Deserialize};
56
57use std::collections::{BTreeMap, HashMap, HashSet};
58use std::fmt::Debug;
59use std::path::PathBuf;
60
61use rpfm_extensions::dependencies::TableReferences;
62use rpfm_extensions::diagnostics::Diagnostics;
63use rpfm_extensions::optimizer::OptimizerOptions;
64use rpfm_extensions::search::{GlobalSearch, MatchHolder};
65use rpfm_extensions::translator::PackTranslation;
66
67use rpfm_lib::compression::CompressionFormat;
68use rpfm_lib::files::{
69    anim_fragment_battle::AnimFragmentBattle, anims_table::AnimsTable, atlas::Atlas, audio::Audio,
70    bmd::Bmd, db::DB, esf::ESF, group_formations::GroupFormations, image::Image, loc::Loc,
71    matched_combat::MatchedCombat, pack::PackSettings, portrait_settings::PortraitSettings,
72    rigidmodel::RigidModel, text::Text, uic::UIC, unit_variant::UnitVariant,
73    video::SupportedFormats, ContainerPath, RFile, RFileDecoded,
74};
75use rpfm_lib::games::pfh_file_type::PFHFileType;
76use rpfm_lib::integrations::git::GitResponse;
77use rpfm_lib::notes::Note;
78use rpfm_lib::schema::{Definition, DefinitionPatch, Field, Schema};
79
80use crate::helpers::*;
81use crate::settings_keys::SettingsSnapshot;
82
83//-------------------------------------------------------------------------------//
84//                              Enums & Structs
85//-------------------------------------------------------------------------------//
86
87/// This struct is a wrapper for all messages (commands and responses) sent between the UI and the server.
88///
89/// It includes a unique ID to correlate responses with their original requests.
90#[derive(Debug, Serialize, Deserialize)]
91pub struct Message<T: Debug> {
92    pub id: u64,
93    pub data: T,
94}
95
96/// This enum represents the current operational mode for a pack.
97///
98/// A pack can either be in normal mode or in MyMod mode, which links it to
99/// a specific game folder and mod name for import/export operations.
100#[derive(Debug, Default, Clone, Serialize, Deserialize)]
101pub enum OperationalMode {
102
103    /// MyMod mode enabled. Contains the game folder name (e.g. "warhammer_2") and the MyMod pack name.
104    MyMod(String, String),
105
106    /// Normal mode - no MyMod association.
107    #[default]
108    Normal,
109}
110
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct CeoEntryData {
114    pub name: String,
115    pub option: String,
116    pub element: String,
117    pub gender: String,
118    pub traits: Vec<(String, String)>, // (uuid, internal_key)
119    pub expanded: bool,
120}
121
122/// This enum defines the commands (messages) you can send to the background thread in order to execute actions.
123///
124/// Each command should include the data needed for his own execution. For a more detailed explanation, check the
125/// docs of each command.
126#[derive(Debug, Serialize, Deserialize)]
127pub enum Command {
128
129    /// Close the background thread. Do not use this command directly.
130    ///
131    /// Response: None (breaks the loop).
132    Exit,
133
134    /// Signal that the client is intentionally disconnecting.
135    ///
136    /// This allows the server to immediately clean up the session's resources instead of
137    /// waiting for the timeout. If this was the last active session, the server will also
138    /// shut down.
139    ///
140    /// Response: [`Response::Success`] (sent before cleanup begins).
141    ClientDisconnecting,
142
143    //-----------------------------------------------------------------------//
144    // PackFile Operations
145    //-----------------------------------------------------------------------//
146
147    /// Closes a specific open Pack identified by its pack key.
148    ///
149    /// Response: [`Response::Success`].
150    ClosePack(String),
151
152    /// Closes all currently open Packs.
153    ///
154    /// Response: [`Response::Success`].
155    CloseAllPacks,
156
157    /// Clean a specific open Pack from corrupted/undecoded files and try to save it to disk.
158    /// First field is the pack key, second is the destination path.
159    ///
160    /// Only use this command if your Pack is not save-able otherwise.
161    ///
162    /// Response:
163    /// - [`Response::ContainerInfo`] on success.
164    /// - [`Response::Error`] on failure.
165    CleanAndSavePackAs(String, PathBuf),
166
167    /// List all currently open packs with their keys and metadata.
168    ///
169    /// Response: [`Response::VecStringContainerInfo`].
170    ListOpenPacks,
171
172    /// Creates a new empty Pack.
173    ///
174    /// Response: [`Response::String`] with the assigned pack key.
175    NewPack,
176
177    /// Save a specific open Pack to disk. The field is the pack key.
178    ///
179    /// Response:
180    /// - [`Response::ContainerInfo`] on success.
181    /// - [`Response::Error`] on failure.
182    SavePack(String),
183
184    /// Save a specific open Pack to a new path.
185    /// First field is the pack key, second is the destination path.
186    ///
187    /// Response:
188    /// - [`Response::ContainerInfo`] on success.
189    /// - [`Response::Error`] on failure.
190    SavePackAs(String, PathBuf),
191
192    /// Get the data used to build the `TreeView` for a specific pack.
193    /// The field is the pack key.
194    ///
195    /// Response:
196    /// - [`Response::ContainerInfoVecRFileInfo`].
197    GetPackFileDataForTreeView(String),
198
199    /// Open one or more `PackFiles` and merge them. Requires the paths of the `PackFiles`].
200    ///
201    /// Response:
202    /// - [`Response::StringContainerInfo`] (pack_key, info) on success.
203    /// - [`Response::Error`] on failure.
204    OpenPackFiles(Vec<PathBuf>),
205
206    /// Open all the CA PackFiles for the selected game as one merged PackFile.
207    ///
208    /// Response:
209    /// - [`Response::StringContainerInfo`] (pack_key, info) on success.
210    /// - [`Response::Error`] on failure.
211    LoadAllCAPackFiles,
212
213    /// Get the `RFileInfo` of one or more `PackedFiles` from a specific pack.
214    /// First field is the pack key, second is the list of file paths.
215    ///
216    /// Response: [`Response::VecRFileInfo`].
217    GetPackedFilesInfo(String, Vec<String>),
218
219    /// Perform a `Global Search` on a specific pack. Requires the pack key and search configuration.
220    ///
221    /// Response:
222    /// - [`Response::GlobalSearchVecRFileInfo`] on success.
223    /// - [`Response::Error`] if no schema.
224    GlobalSearch(String, GlobalSearch),
225
226    /// Change the `Game Selected`]. Contains the game key and whether to rebuild dependencies.
227    ///
228    /// Response:
229    /// - [`Response::CompressionFormatDependenciesInfo`] on success.
230    /// - [`Response::Error`] if game not supported.
231    SetGameSelected(String, bool),
232
233    /// Get the currently selected game key.
234    ///
235    /// Response: [`Response::String`].
236    GetGameSelected,
237
238    /// Change the `Type` of a specific open Pack.
239    /// First field is the pack key, second is the new type.
240    ///
241    /// Response: [`Response::Success`].
242    SetPackFileType(String, PFHFileType),
243
244    /// Generate the dependencies cache for the selected game.
245    ///
246    /// Response:
247    /// - [`Response::DependenciesInfo`] on success.
248    /// - [`Response::Error`] on failure.
249    GenerateDependenciesCache,
250
251    /// Update the currently loaded Schema with data from the game's Assembly Kit.
252    ///
253    /// Response:
254    /// - [`Response::Success`] on success.
255    /// - [`Response::Error`] on failure.
256    UpdateCurrentSchemaFromAssKit,
257
258    /// Trigger an optimization pass over a specific open Pack.
259    /// First field is the pack key, second is the optimizer options.
260    ///
261    /// Response:
262    /// - [`Response::HashSetStringHashSetString`] (deleted paths, added paths) on success.
263    /// - [`Response::Error`] on failure.
264    OptimizePackFile(String, OptimizerOptions),
265
266    /// Patch the SiegeAI of a Siege Map for Warhammer games in a specific pack.
267    /// The field is the pack key.
268    ///
269    /// Response:
270    /// - [`Response::StringVecContainerPath`] on success.
271    /// - [`Response::Error`] on failure.
272    PatchSiegeAI(String),
273
274    /// Change the `Index Includes Timestamp` flag in a specific open Pack.
275    /// First field is the pack key, second is the flag value.
276    ///
277    /// Response: [`Response::Success`].
278    ChangeIndexIncludesTimestamp(String, bool),
279
280    /// Change the compression format of a specific open Pack.
281    /// First field is the pack key, second is the compression format.
282    ///
283    /// Response:
284    /// - [`Response::CompressionFormat`] (the actual format set, may differ if unsupported).
285    ChangeCompressionFormat(String, CompressionFormat),
286
287    /// Get the current path of a specific open Pack.
288    /// The field is the pack key.
289    ///
290    /// Response: [`Response::PathBuf`].
291    GetPackFilePath(String),
292
293    /// Get the info of a single `PackedFile` from a specific pack.
294    /// First field is the pack key, second is the file path.
295    ///
296    /// Response: [`Response::OptionRFileInfo`].
297    GetRFileInfo(String, String),
298
299    //-----------------------------------------------------------------------//
300    // Update Commands
301    //-----------------------------------------------------------------------//
302
303    /// Check if there is an RPFM update available.
304    ///
305    /// Response:
306    /// - [`Response::APIResponse`] on success.
307    /// - [`Response::Error`] on failure.
308    CheckUpdates,
309
310    /// Check if there is a Schema update available.
311    ///
312    /// Response:
313    /// - [`Response::APIResponseGit`] on success.
314    /// - [`Response::Error`] on failure.
315    CheckSchemaUpdates,
316
317    /// Update the schemas from the remote repository.
318    ///
319    /// Response:
320    /// - [`Response::Success`] on success.
321    /// - [`Response::Error`] on failure.
322    UpdateSchemas,
323
324    /// Check if there is a Dependency Database loaded in memory.
325    /// Pass true to ensure dependencies were built with the AssKit.
326    ///
327    /// Response: [`Response::Bool`].
328    IsThereADependencyDatabase(bool),
329
330    //-----------------------------------------------------------------------//
331    // PackedFile Operations
332    //-----------------------------------------------------------------------//
333
334    /// Create a new `PackedFile` inside a specific open Pack.
335    /// First field is the pack key, then path and NewFile info.
336    ///
337    /// Response:
338    /// - [`Response::Success`] on success.
339    /// - [`Response::Error`] on failure.
340    NewPackedFile(String, String, NewFile),
341
342    /// Add one or more Files to a specific open Pack.
343    /// First field is the pack key, then source filesystem paths, destination container paths, optional paths to ignore.
344    ///
345    /// Response:
346    /// - [`Response::VecContainerPathOptionString`] (added paths, optional error message).
347    AddPackedFiles(String, Vec<PathBuf>, Vec<ContainerPath>, Option<Vec<PathBuf>>),
348
349    /// Decode a PackedFile to be shown on the UI.
350    /// First field is the pack key, then the path of the file and its data source.
351    ///
352    /// Response:
353    /// - [`Response::AnimFragmentBattleRFileInfo`] for AnimFragmentBattle files.
354    /// - [`Response::AnimPackRFileInfo`] for AnimPack files.
355    /// - [`Response::AnimsTableRFileInfo`] for AnimsTable files.
356    /// - [`Response::AtlasRFileInfo`] for Atlas files.
357    /// - [`Response::AudioRFileInfo`] for Audio files.
358    /// - [`Response::BmdRFileInfo`] for BMD files.
359    /// - [`Response::DBRFileInfo`] for DB table files.
360    /// - [`Response::ESFRFileInfo`] for ESF files.
361    /// - [`Response::GroupFormationsRFileInfo`] for GroupFormations files.
362    /// - [`Response::ImageRFileInfo`] for Image files.
363    /// - [`Response::LocRFileInfo`] for Loc files.
364    /// - [`Response::MatchedCombatRFileInfo`] for MatchedCombat files.
365    /// - [`Response::PortraitSettingsRFileInfo`] for PortraitSettings files.
366    /// - [`Response::RigidModelRFileInfo`] for RigidModel files.
367    /// - [`Response::TextRFileInfo`] for Text files.
368    /// - [`Response::UICRFileInfo`] for UIC files.
369    /// - [`Response::UnitVariantRFileInfo`] for UnitVariant files.
370    /// - [`Response::VideoInfoRFileInfo`] for Video files.
371    /// - [`Response::VMDRFileInfo`] for VMD files.
372    /// - [`Response::WSModelRFileInfo`] for WSModel files.
373    /// - [`Response::Text`] for pack notes.
374    /// - [`Response::Unknown`] for unsupported types.
375    /// - [`Response::Error`] on failure.
376    DecodePackedFile(String, String, DataSource),
377
378    /// Save an edited `PackedFile` back to a specific Pack.
379    /// First field is the pack key, then path and decoded file data.
380    ///
381    /// Response: [`Response::Success`].
382    SavePackedFileFromView(String, String, RFileDecoded),
383
384    /// Add PackedFiles from one open pack into another.
385    /// First field is the target pack key, second is the source pack key, third is the paths to copy.
386    ///
387    /// Response:
388    /// - [`Response::VecContainerPath`] on success.
389    /// - [`Response::Error`] if source pack not found.
390    AddPackedFilesFromPackFile(String, String, Vec<ContainerPath>),
391
392    /// Add PackedFiles from a specific pack to an AnimPack.
393    /// First field is the pack key, then animpack path and container paths.
394    ///
395    /// Response:
396    /// - [`Response::VecContainerPath`] on success.
397    /// - [`Response::Error`] on failure.
398    AddPackedFilesFromPackFileToAnimpack(String, String, Vec<ContainerPath>),
399
400    /// Add PackedFiles from an AnimPack to a specific pack.
401    /// First field is the pack key, then data source, animpack path, and container paths.
402    ///
403    /// Response:
404    /// - [`Response::VecContainerPath`] on success.
405    /// - [`Response::Error`] on failure.
406    AddPackedFilesFromAnimpack(String, DataSource, String, Vec<ContainerPath>),
407
408    /// Delete PackedFiles from an AnimPack in a specific pack.
409    /// First field is the pack key, then animpack path and container paths.
410    ///
411    /// Response:
412    /// - [`Response::Success`] on success.
413    /// - [`Response::Error`] on failure.
414    DeleteFromAnimpack(String, String, Vec<ContainerPath>),
415
416    /// Delete one or more PackedFiles from a specific pack.
417    /// First field is the pack key, second is the paths to delete.
418    ///
419    /// Response:
420    /// - [`Response::VecContainerPath`] (deleted paths).
421    DeletePackedFiles(String, Vec<ContainerPath>),
422
423    /// Copy one or more PackedFiles to the internal clipboard.
424    /// The field is a map of pack key to the paths to copy from that pack.
425    /// This stores path references in a server-side clipboard for later pasting.
426    ///
427    /// Response:
428    /// - [`Response::Success`] on success.
429    /// - [`Response::Error`] on failure.
430    CopyPackedFiles(BTreeMap<String, Vec<ContainerPath>>),
431
432    /// Cut one or more PackedFiles to the internal clipboard.
433    /// Same as copy, but the files will be removed from the source pack on paste.
434    /// The field is a map of pack key to the paths to cut from that pack.
435    ///
436    /// Response:
437    /// - [`Response::Success`] on success.
438    /// - [`Response::Error`] on failure.
439    CutPackedFiles(BTreeMap<String, Vec<ContainerPath>>),
440
441    /// Paste PackedFiles from the internal clipboard into a pack.
442    /// First field is the target pack key, second is the destination folder path.
443    ///
444    /// Response:
445    /// - [`Response::VecContainerPathVecContainerPathString`] (added paths, cut-deleted paths, source pack key) on success.
446    /// - [`Response::Error`] on failure.
447    PastePackedFiles(String, String),
448
449    /// Duplicate one or more PackedFiles in-place within the same pack.
450    /// First field is the pack key, second is the paths to duplicate.
451    /// Files are cloned with a numeric suffix added to avoid name collisions.
452    ///
453    /// Response:
454    /// - [`Response::VecContainerPath`] (new duplicated paths) on success.
455    /// - [`Response::Error`] on failure.
456    DuplicatePackedFiles(String, Vec<ContainerPath>),
457
458    /// Extract one or more PackedFiles from a pack.
459    /// First field is the pack key, then paths by data source, extraction path, whether to export tables as TSV.
460    ///
461    /// Response:
462    /// - [`Response::StringVecPathBuf`] on success.
463    /// - [`Response::Error`] on failure.
464    ExtractPackedFiles(String, BTreeMap<DataSource, Vec<ContainerPath>>, PathBuf, bool),
465
466    /// Rename one or more PackedFiles in a specific pack.
467    /// First field is the pack key, second is a Vec with original and new ContainerPaths.
468    ///
469    /// Response:
470    /// - [`Response::VecContainerPathContainerPath`] on success.
471    /// - [`Response::Error`] on failure.
472    RenamePackedFiles(String, Vec<(ContainerPath, ContainerPath)>),
473
474    /// Check if a folder exists in a specific open PackFile.
475    /// First field is the pack key, second is the folder path.
476    ///
477    /// Response: [`Response::Bool`].
478    FolderExists(String, String),
479
480    /// Check if a PackedFile exists in a specific open PackFile.
481    /// First field is the pack key, second is the file path.
482    ///
483    /// Response: [`Response::Bool`].
484    PackedFileExists(String, String),
485
486    //-----------------------------------------------------------------------//
487    // Dependency Commands
488    //-----------------------------------------------------------------------//
489
490    /// Get the table names of all DB files in dependency PackFiles.
491    ///
492    /// Response: [`Response::VecString`].
493    GetTableListFromDependencyPackFile,
494
495    /// Get custom table names (start_pos_, twad_ prefixes) from the schema.
496    ///
497    /// Response:
498    /// - [`Response::VecString`] on success.
499    /// - [`Response::Error`] if no schema.
500    GetCustomTableList,
501
502    /// Get local art set IDs from campaign_character_arts_tables in a specific pack.
503    /// The field is the pack key.
504    ///
505    /// Response: [`Response::HashSetString`].
506    LocalArtSetIds(String),
507
508    /// Get art set IDs from dependencies' campaign_character_arts_tables.
509    ///
510    /// Response: [`Response::HashSetString`].
511    DependenciesArtSetIds,
512
513    /// Get the version of a table from the dependency database.
514    ///
515    /// Response:
516    /// - [`Response::I32`] on success.
517    /// - [`Response::Error`] if not found or dependencies not loaded.
518    GetTableVersionFromDependencyPackFile(String),
519
520    /// Get the definition of a table from the dependency database.
521    ///
522    /// Response:
523    /// - [`Response::Definition`] on success.
524    /// - [`Response::Error`] if not found.
525    GetTableDefinitionFromDependencyPackFile(String),
526
527    /// Merge multiple compatible tables into one in a specific pack.
528    /// First field is the pack key, then paths to merge, merged file path, delete source flag.
529    ///
530    /// Response:
531    /// - [`Response::String`] (merged path) on success.
532    /// - [`Response::Error`] on failure.
533    MergeFiles(String, Vec<ContainerPath>, String, bool),
534
535    /// Update a table to a newer version in a specific pack.
536    /// First field is the pack key, second is the container path.
537    ///
538    /// Response:
539    /// - [`Response::I32I32VecStringVecString`] (old_version, new_version, deleted_fields, added_fields) on success.
540    /// - [`Response::Error`] on failure.
541    UpdateTable(String, ContainerPath),
542
543    //-----------------------------------------------------------------------//
544    // Search Commands
545    //-----------------------------------------------------------------------//
546
547    /// Replace specific matches in a Global Search on a specific pack.
548    /// First field is the pack key, then search config and match holders.
549    ///
550    /// Response:
551    /// - [`Response::GlobalSearchVecRFileInfo`] on success.
552    /// - [`Response::Error`] if no schema.
553    GlobalSearchReplaceMatches(String, GlobalSearch, Vec<MatchHolder>),
554
555    /// Replace all matches in a Global Search on a specific pack.
556    /// First field is the pack key, second is the search config.
557    ///
558    /// Response:
559    /// - [`Response::GlobalSearchVecRFileInfo`] on success.
560    /// - [`Response::Error`] if no schema.
561    GlobalSearchReplaceAll(String, GlobalSearch),
562
563    /// Get reference data for columns in a definition from a specific pack.
564    /// First field is the pack key, then table name, definition, force flag.
565    ///
566    /// Response: [`Response::HashMapI32TableReferences`].
567    GetReferenceDataFromDefinition(String, String, Definition, bool),
568
569    /// Get the list of PackFiles marked as dependencies of a specific pack.
570    /// The field is the pack key.
571    ///
572    /// Response: [`Response::VecBoolString`].
573    GetDependencyPackFilesList(String),
574
575    /// Set the list of PackFiles marked as dependencies of a specific pack.
576    /// First field is the pack key, second is the dependency list.
577    ///
578    /// Response: [`Response::Success`].
579    SetDependencyPackFilesList(String, Vec<(bool, String)>),
580
581    /// Get PackedFiles from all known sources (PackFile, GameFiles, ParentFiles).
582    /// Requires: paths to get, whether to lowercase paths.
583    ///
584    /// Response: [`Response::HashMapDataSourceHashMapStringRFile`].
585    GetRFilesFromAllSources(Vec<ContainerPath>, bool),
586
587    //-----------------------------------------------------------------------//
588    // Video Commands
589    //-----------------------------------------------------------------------//
590
591    /// Change the format of a ca_vp8 video PackedFile in a specific pack.
592    /// First field is the pack key, then file path and format.
593    ///
594    /// Response:
595    /// - [`Response::Success`] on success.
596    /// - [`Response::Error`] on failure.
597    SetVideoFormat(String, String, SupportedFormats),
598
599    //-----------------------------------------------------------------------//
600    // Schema Commands
601    //-----------------------------------------------------------------------//
602
603    /// Save the provided schema to disk.
604    ///
605    /// Response:
606    /// - [`Response::Success`] on success.
607    /// - [`Response::Error`] on failure.
608    SaveSchema(Schema),
609
610    /// Encode and clean the cache for the provided paths in a specific pack.
611    /// First field is the pack key, second is the paths to clean.
612    ///
613    /// Response: [`Response::Success`].
614    CleanCache(String, Vec<ContainerPath>),
615
616    //-----------------------------------------------------------------------//
617    // TSV Commands
618    //-----------------------------------------------------------------------//
619
620    /// Export a table as TSV from a specific pack.
621    /// First field is the pack key, then internal path, destination path, data source.
622    ///
623    /// Response:
624    /// - [`Response::Success`] on success.
625    /// - [`Response::Error`] on failure.
626    ExportTSV(String, String, PathBuf, DataSource),
627
628    /// Import a TSV as a table into a specific pack.
629    /// First field is the pack key, then internal path, source TSV path.
630    ///
631    /// Response:
632    /// - [`Response::RFileDecoded`] on success.
633    /// - [`Response::Error`] on failure.
634    ImportTSV(String, String, PathBuf),
635
636    //-----------------------------------------------------------------------//
637    // External Program Commands
638    //-----------------------------------------------------------------------//
639
640    /// Open the folder containing a specific open PackFile in the file manager.
641    /// The field is the pack key.
642    ///
643    /// Response:
644    /// - [`Response::Success`] on success.
645    /// - [`Response::Error`] if pack doesn't exist on disk.
646    OpenContainingFolder(String),
647
648    /// Open a PackedFile in an external program.
649    /// First field is the pack key, then data source and container path.
650    ///
651    /// Response:
652    /// - [`Response::PathBuf`] (extracted path) on success.
653    /// - [`Response::Error`] on failure.
654    OpenPackedFileInExternalProgram(String, DataSource, ContainerPath),
655
656    /// Save a PackedFile from an external program to a specific pack.
657    /// First field is the pack key, then internal path, external file path.
658    ///
659    /// Response:
660    /// - [`Response::Success`] on success.
661    /// - [`Response::Error`] on failure.
662    SavePackedFileFromExternalView(String, String, PathBuf),
663
664    //-----------------------------------------------------------------------//
665    // Program Update Commands
666    //-----------------------------------------------------------------------//
667
668    /// Update the program to the latest version available.
669    ///
670    /// Response:
671    /// - [`Response::Success`] on success.
672    /// - [`Response::Error`] on failure.
673    UpdateMainProgram,
674
675    /// Trigger an autosave to a backup for a specific pack.
676    /// The field is the pack key.
677    ///
678    /// Response: [`Response::Success`].
679    TriggerBackupAutosave(String),
680
681    //-----------------------------------------------------------------------//
682    // Diagnostics Commands
683    //-----------------------------------------------------------------------//
684
685    /// Trigger a full diagnostics check over all open Packs.
686    /// First field is ignored diagnostics, then check AK-only references.
687    ///
688    /// Response: [`Response::Diagnostics`].
689    DiagnosticsCheck(Vec<String>, bool),
690
691    /// Trigger a partial diagnostics update over all open packs.
692    /// First field is existing diagnostics, then paths to check, check AK-only references.
693    ///
694    /// Response: [`Response::Diagnostics`].
695    DiagnosticsUpdate(Diagnostics, Vec<ContainerPath>, bool),
696
697    //-----------------------------------------------------------------------//
698    // Pack Settings Commands
699    //-----------------------------------------------------------------------//
700
701    /// Get the settings of a specific open PackFile.
702    /// The field is the pack key.
703    ///
704    /// Response: [`Response::PackSettings`].
705    GetPackSettings(String),
706
707    /// Set the settings of a specific open PackFile.
708    /// First field is the pack key, second is the settings.
709    ///
710    /// Response: [`Response::Success`].
711    SetPackSettings(String, PackSettings),
712
713    //-----------------------------------------------------------------------//
714    // Debug Commands
715    //-----------------------------------------------------------------------//
716
717    /// Export missing table definitions from a specific pack to a file (for debugging).
718    /// The field is the pack key.
719    ///
720    /// Response: [`Response::Success`].
721    GetMissingDefinitions(String),
722
723    //-----------------------------------------------------------------------//
724    // Dependencies Commands
725    //-----------------------------------------------------------------------//
726
727    /// Rebuild the dependencies.
728    /// Pass true to rebuild all dependencies, false for mod-specific only.
729    ///
730    /// Response:
731    /// - [`Response::DependenciesInfo`] on success.
732    /// - [`Response::Error`] if no schema.
733    RebuildDependencies(bool),
734
735    //-----------------------------------------------------------------------//
736    // Cascade Edition Commands
737    //-----------------------------------------------------------------------//
738
739    /// Trigger a cascade edition on all referenced data in a specific pack.
740    /// First field is the pack key, then table name, definition, list of (field, old_value, new_value).
741    ///
742    /// Response: [`Response::VecContainerPathVecRFileInfo`].
743    CascadeEdition(String, String, Definition, Vec<(Field, String, String)>),
744
745    //-----------------------------------------------------------------------//
746    // Navigation Commands
747    //-----------------------------------------------------------------------//
748
749    /// Go to the definition of a reference in a specific pack.
750    /// First field is the pack key, then table, column, values to search.
751    ///
752    /// Response:
753    /// - [`Response::DataSourceStringUsizeUsize`] on success.
754    /// - [`Response::Error`] if not found.
755    GoToDefinition(String, String, String, Vec<String>),
756
757    /// Get the source data of a loc key from a specific pack.
758    /// First field is the pack key, second is the loc key.
759    ///
760    /// Response: [`Response::OptionStringStringVecString`].
761    GetSourceDataFromLocKey(String, String),
762
763    /// Go to a loc key's location in a specific pack.
764    /// First field is the pack key, second is the loc key to search.
765    ///
766    /// Response:
767    /// - [`Response::DataSourceStringUsizeUsize`] on success.
768    /// - [`Response::Error`] if not found.
769    GoToLoc(String, String),
770
771    /// Find all references to a value in a specific pack.
772    /// First field is the pack key, then map of table -> columns to search, value to search.
773    ///
774    /// Response: [`Response::VecDataSourceStringStringStringUsizeUsize`].
775    SearchReferences(String, HashMap<String, Vec<String>>, String),
776
777    /// Get the name of a specific open PackFile.
778    /// The field is the pack key.
779    ///
780    /// Response: [`Response::String`].
781    GetPackFileName(String),
782
783    /// Get the raw binary data of a PackedFile from a specific pack.
784    /// First field is the pack key, second is the file path.
785    ///
786    /// Response:
787    /// - [`Response::VecU8`] on success.
788    /// - [`Response::Error`] on failure.
789    GetPackedFileRawData(String, String),
790
791    /// Import files from dependencies into a specific open PackFile.
792    /// First field is the pack key, second is the paths by data source.
793    ///
794    /// Response:
795    /// - [`Response::VecContainerPathVecString`] (added paths, failed paths).
796    /// - [`Response::Error`] on failure.
797    ImportDependenciesToOpenPackFile(String, BTreeMap<DataSource, Vec<ContainerPath>>),
798
799    /// Save PackedFiles to a specific PackFile and optionally optimize.
800    /// First field is the pack key, then files to save, whether to optimize.
801    ///
802    /// Response:
803    /// - [`Response::VecContainerPathVecContainerPath`] (added paths, deleted paths) on success.
804    /// - [`Response::Error`] on failure.
805    SavePackedFilesToPackFileAndClean(String, Vec<RFile>, bool),
806
807    /// Get all file names under a path in all dependencies.
808    ///
809    /// Response: [`Response::HashMapDataSourceHashSetContainerPath`].
810    GetPackedFilesNamesStartingWitPathFromAllSources(ContainerPath),
811
812    //-----------------------------------------------------------------------//
813    // Notes Commands
814    //-----------------------------------------------------------------------//
815
816    /// Get all notes under a path in a specific pack.
817    /// First field is the pack key, second is the path.
818    ///
819    /// Response: [`Response::VecNote`].
820    NotesForPath(String, String),
821
822    /// Add a note to a specific pack.
823    /// First field is the pack key, second is the note.
824    ///
825    /// Response: [`Response::Note`].
826    AddNote(String, Note),
827
828    /// Delete a note from a specific pack.
829    /// First field is the pack key, then path and note ID.
830    ///
831    /// Response: [`Response::Success`].
832    DeleteNote(String, String, u64),
833
834    //-----------------------------------------------------------------------//
835    // Schema Patch Commands
836    //-----------------------------------------------------------------------//
837
838    /// Save local schema patches.
839    ///
840    /// Response:
841    /// - [`Response::Success`] on success.
842    /// - [`Response::Error`] on failure.
843    SaveLocalSchemaPatch(HashMap<String, DefinitionPatch>),
844
845    /// Remove local schema patches for a table.
846    ///
847    /// Response:
848    /// - [`Response::Success`] on success.
849    /// - [`Response::Error`] on failure.
850    RemoveLocalSchemaPatchesForTable(String),
851
852    /// Remove local schema patches for a specific field in a table.
853    ///
854    /// Response:
855    /// - [`Response::Success`] on success.
856    /// - [`Response::Error`] on failure.
857    RemoveLocalSchemaPatchesForTableAndField(String, String),
858
859    /// Import a schema patch into the local schema patches.
860    ///
861    /// Response:
862    /// - [`Response::Success`] on success.
863    /// - [`Response::Error`] on failure.
864    ImportSchemaPatch(HashMap<String, DefinitionPatch>),
865
866    //-----------------------------------------------------------------------//
867    // Loc Generation Commands
868    //-----------------------------------------------------------------------//
869
870    /// Generate all missing loc entries for a specific open PackFile.
871    /// The field is the pack key.
872    ///
873    /// Response:
874    /// - [`Response::VecContainerPath`] on success.
875    /// - [`Response::Error`] on failure.
876    GenerateMissingLocData(String),
877
878    //-----------------------------------------------------------------------//
879    // Lua Autogen Commands
880    //-----------------------------------------------------------------------//
881
882    /// Check for updates on the tw_autogen repository.
883    ///
884    /// Response:
885    /// - [`Response::APIResponseGit`] on success.
886    /// - [`Response::Error`] on failure.
887    CheckLuaAutogenUpdates,
888
889    /// Update the tw_autogen repository.
890    ///
891    /// Response:
892    /// - [`Response::Success`] on success.
893    /// - [`Response::Error`] on failure.
894    UpdateLuaAutogen,
895
896    //-----------------------------------------------------------------------//
897    // MyMod Commands
898    //-----------------------------------------------------------------------//
899
900    /// Initialize a MyMod folder.
901    /// Requires: mod name, game key, sublime support, vscode support, git support (gitignore content).
902    ///
903    /// Response:
904    /// - [`Response::PathBuf`] (path to the new pack) on success.
905    /// - [`Response::Error`] on failure.
906    InitializeMyModFolder(String, String, bool, bool, Option<String>),
907
908    /// Live export a specific PackFile to the game folder.
909    /// The field is the pack key.
910    ///
911    /// Response:
912    /// - [`Response::Success`] on success.
913    /// - [`Response::Error`] on failure.
914    LiveExport(String),
915
916    /// Set the operational mode for a specific pack.
917    /// First field is the pack key, second is the new operational mode.
918    ///
919    /// Response: [`Response::Success`].
920    SetPackOperationalMode(String, OperationalMode),
921
922    /// Get the operational mode for a specific pack.
923    /// The field is the pack key.
924    ///
925    /// Response: [`Response::OperationalMode`].
926    GetPackOperationalMode(String),
927
928    //-----------------------------------------------------------------------//
929    // Map Packing Commands
930    //-----------------------------------------------------------------------//
931
932    /// Pack map tiles into a specific PackFile.
933    /// First field is the pack key, then tile map paths, list of (tile path, name).
934    ///
935    /// Response:
936    /// - [`Response::VecContainerPathVecContainerPath`] (added paths, deleted paths) on success.
937    /// - [`Response::Error`] on failure.
938    PackMap(String, Vec<PathBuf>, Vec<(PathBuf, String)>),
939
940    //-----------------------------------------------------------------------//
941    // Diagnostics Ignore Commands
942    //-----------------------------------------------------------------------//
943
944    /// Add a line to a specific pack's ignored diagnostics.
945    /// First field is the pack key, second is the diagnostic line.
946    ///
947    /// Response: [`Response::Success`].
948    AddLineToPackIgnoredDiagnostics(String, String),
949
950    //-----------------------------------------------------------------------//
951    // Empire/Napoleon AK Commands
952    //-----------------------------------------------------------------------//
953
954    /// Check for updates on the old AK files repository.
955    ///
956    /// Response:
957    /// - [`Response::APIResponseGit`] on success.
958    /// - [`Response::Error`] on failure.
959    CheckEmpireAndNapoleonAKUpdates,
960
961    /// Update the old AK files repository.
962    ///
963    /// Response:
964    /// - [`Response::Success`] on success.
965    /// - [`Response::Error`] on failure.
966    UpdateEmpireAndNapoleonAK,
967
968    //-----------------------------------------------------------------------//
969    // Translation Commands
970    //-----------------------------------------------------------------------//
971
972    /// Get pack translation data for a language from a specific pack.
973    /// First field is the pack key, second is the language.
974    ///
975    /// Response:
976    /// - [`Response::PackTranslation`] on success.
977    /// - [`Response::Error`] on failure.
978    GetPackTranslation(String, String),
979
980    /// Check for translation updates.
981    ///
982    /// Response:
983    /// - [`Response::APIResponseGit`] on success.
984    /// - [`Response::Error`] on failure.
985    CheckTranslationsUpdates,
986
987    /// Update the translations repository.
988    ///
989    /// Response:
990    /// - [`Response::Success`] on success.
991    /// - [`Response::Error`] on failure.
992    UpdateTranslations,
993
994    //-----------------------------------------------------------------------//
995    // Starpos Commands
996    //-----------------------------------------------------------------------//
997
998    /// Build starpos (pre-processing step) for a specific pack.
999    /// First field is the pack key, then campaign ID, process HLP/SPD data.
1000    ///
1001    /// Response:
1002    /// - [`Response::Success`] on success.
1003    /// - [`Response::Error`] on failure.
1004    BuildStarpos(String, String, bool),
1005
1006    /// Build starpos (post-processing step) for a specific pack.
1007    /// First field is the pack key, then campaign ID, process HLP/SPD data.
1008    ///
1009    /// Response:
1010    /// - [`Response::VecContainerPath`] on success.
1011    /// - [`Response::Error`] on failure.
1012    BuildStarposPost(String, String, bool),
1013
1014    /// Clean up starpos temporary files for a specific pack.
1015    /// First field is the pack key, then campaign ID, process HLP/SPD data.
1016    ///
1017    /// Response:
1018    /// - [`Response::Success`] on success.
1019    /// - [`Response::Error`] on failure.
1020    BuildStarposCleanup(String, String, bool),
1021
1022    /// Get campaign IDs for starpos building from a specific pack.
1023    /// The field is the pack key.
1024    ///
1025    /// Response: [`Response::HashSetString`].
1026    BuildStarposGetCampaingIds(String),
1027
1028    /// Check if victory conditions file exists in a specific pack (required for some games).
1029    /// The field is the pack key.
1030    ///
1031    /// Response:
1032    /// - [`Response::Success`] if exists or not needed.
1033    /// - [`Response::Error`] if missing.
1034    BuildStarposCheckVictoryConditions(String),
1035
1036
1037    //-----------------------------------------------------------------------//
1038    // CEO Commands
1039    //-----------------------------------------------------------------------//
1040
1041    BuildCeo(String, String, String),
1042
1043    /// Import ceo_data.ccd into the open pack after BOB has run.
1044    /// Field is the pack key.
1045    ///
1046    /// Response:
1047    /// - [`Response::VecContainerPath`] on success.
1048    /// - [`Response::Error`] on failure.
1049    BuildCeoPost(String, String),  // pack_key, akit_path
1050
1051    BuildCeoEntries(String, Vec<CeoEntryData>),  // pack_key, entries
1052
1053
1054    GetTraitCeos,
1055
1056    //-----------------------------------------------------------------------//
1057    // Animation Commands
1058    //-----------------------------------------------------------------------//
1059
1060    /// Update animation IDs with offset in a specific pack.
1061    /// First field is the pack key, then starting ID, offset.
1062    ///
1063    /// Response:
1064    /// - [`Response::VecContainerPath`] on success.
1065    /// - [`Response::Error`] on failure.
1066    UpdateAnimIds(String, i32, i32),
1067
1068    /// Get animation paths by skeleton name.
1069    ///
1070    /// Response: [`Response::HashSetString`].
1071    GetAnimPathsBySkeletonName(String),
1072
1073    //-----------------------------------------------------------------------//
1074    // Table Commands
1075    //-----------------------------------------------------------------------//
1076
1077    /// Get tables from dependencies by table name.
1078    ///
1079    /// Response:
1080    /// - [`Response::VecRFile`] on success.
1081    /// - [`Response::Error`] on failure.
1082    GetTablesFromDependencies(String),
1083
1084    /// Get table paths by table name from a specific PackFile.
1085    /// First field is the pack key, second is the table name.
1086    ///
1087    /// Response: [`Response::VecString`].
1088    GetTablesByTableName(String, String),
1089
1090    /// Add keys to the key_deletes table in a specific pack.
1091    /// First field is the pack key, then table file name, key table name, keys to add.
1092    ///
1093    /// Response: [`Response::OptionContainerPath`].
1094    AddKeysToKeyDeletes(String, String, String, HashSet<String>),
1095
1096    //-----------------------------------------------------------------------//
1097    // 3D Export Commands
1098    //-----------------------------------------------------------------------//
1099
1100    /// Export a RigidModel to glTF format.
1101    /// Requires: RigidModel, output path.
1102    ///
1103    /// Response:
1104    /// - [`Response::Success`] on success.
1105    /// - [`Response::Error`] on failure.
1106    ExportRigidToGltf(RigidModel, String),
1107
1108    //-----------------------------------------------------------------------//
1109    // Settings Getter Commands
1110    //-----------------------------------------------------------------------//
1111
1112    /// Get a boolean setting value.
1113    ///
1114    /// Response: [`Response::Bool`].
1115    SettingsGetBool(String),
1116
1117    /// Get an i32 setting value.
1118    ///
1119    /// Response: [`Response::I32`].
1120    SettingsGetI32(String),
1121
1122    /// Get an f32 setting value.
1123    ///
1124    /// Response: [`Response::F32`].
1125    SettingsGetF32(String),
1126
1127    /// Get a string setting value.
1128    ///
1129    /// Response: [`Response::String`].
1130    SettingsGetString(String),
1131
1132    /// Get a PathBuf setting value.
1133    ///
1134    /// Response: [`Response::PathBuf`].
1135    SettingsGetPathBuf(String),
1136
1137    /// Get a `Vec<String>` setting value.
1138    ///
1139    /// Response: [`Response::VecString`].
1140    SettingsGetVecString(String),
1141
1142    /// Get raw data setting value.
1143    ///
1144    /// Response: [`Response::VecU8`].
1145    SettingsGetVecRaw(String),
1146
1147    /// Get all settings at once (for batch loading).
1148    ///
1149    /// This is much more efficient than calling individual SettingsGet* commands
1150    /// when you need multiple settings, as it requires only one IPC round-trip.
1151    ///
1152    /// Response: [`Response::SettingsAll`].
1153    SettingsGetAll,
1154
1155    //-----------------------------------------------------------------------//
1156    // Settings Setter Commands
1157    //-----------------------------------------------------------------------//
1158
1159    /// Set a boolean setting value.
1160    ///
1161    /// Response:
1162    /// - [`Response::Success`] on success.
1163    /// - [`Response::Error`] on failure.
1164    SettingsSetBool(String, bool),
1165
1166    /// Set an i32 setting value.
1167    ///
1168    /// Response:
1169    /// - [`Response::Success`] on success.
1170    /// - [`Response::Error`] on failure.
1171    SettingsSetI32(String, i32),
1172
1173    /// Set an f32 setting value.
1174    ///
1175    /// Response:
1176    /// - [`Response::Success`] on success.
1177    /// - [`Response::Error`] on failure.
1178    SettingsSetF32(String, f32),
1179
1180    /// Set a string setting value.
1181    ///
1182    /// Response:
1183    /// - [`Response::Success`] on success.
1184    /// - [`Response::Error`] on failure.
1185    SettingsSetString(String, String),
1186
1187    /// Set a PathBuf setting value.
1188    ///
1189    /// Response:
1190    /// - [`Response::Success`] on success.
1191    /// - [`Response::Error`] on failure.
1192    SettingsSetPathBuf(String, PathBuf),
1193
1194    /// Set a `Vec<String>` setting value.
1195    ///
1196    /// Response:
1197    /// - [`Response::Success`] on success.
1198    /// - [`Response::Error`] on failure.
1199    SettingsSetVecString(String, Vec<String>),
1200
1201    /// Set raw data setting value.
1202    ///
1203    /// Response:
1204    /// - [`Response::Success`] on success.
1205    /// - [`Response::Error`] on failure.
1206    SettingsSetVecRaw(String, Vec<u8>),
1207
1208    //-----------------------------------------------------------------------//
1209    // Path Commands
1210    //-----------------------------------------------------------------------//
1211
1212    /// Get the config path.
1213    ///
1214    /// Response:
1215    /// - [`Response::PathBuf`] on success.
1216    /// - [`Response::Error`] on failure.
1217    ConfigPath,
1218
1219    /// Get the Assembly Kit path for the current game.
1220    ///
1221    /// Response:
1222    /// - [`Response::PathBuf`] on success.
1223    /// - [`Response::Error`] on failure.
1224    AssemblyKitPath,
1225
1226    /// Get the backup autosave path.
1227    ///
1228    /// Response:
1229    /// - [`Response::PathBuf`] on success.
1230    /// - [`Response::Error`] on failure.
1231    BackupAutosavePath,
1232
1233    /// Get the old AK data path.
1234    ///
1235    /// Response:
1236    /// - [`Response::PathBuf`] on success.
1237    /// - [`Response::Error`] on failure.
1238    OldAkDataPath,
1239
1240    /// Get the schemas path.
1241    ///
1242    /// Response:
1243    /// - [`Response::PathBuf`] on success.
1244    /// - [`Response::Error`] on failure.
1245    SchemasPath,
1246
1247    /// Get the table profiles path.
1248    ///
1249    /// Response:
1250    /// - [`Response::PathBuf`] on success.
1251    /// - [`Response::Error`] on failure.
1252    TableProfilesPath,
1253
1254    /// Get the translations local path.
1255    ///
1256    /// Response:
1257    /// - [`Response::PathBuf`] on success.
1258    /// - [`Response::Error`] on failure.
1259    TranslationsLocalPath,
1260
1261    /// Get the dependencies cache path.
1262    ///
1263    /// Response:
1264    /// - [`Response::PathBuf`] on success.
1265    /// - [`Response::Error`] on failure.
1266    DependenciesCachePath,
1267
1268    /// Clear a config path.
1269    ///
1270    /// Response:
1271    /// - [`Response::Success`] on success.
1272    /// - [`Response::Error`] on failure.
1273    SettingsClearPath(PathBuf),
1274
1275    //-----------------------------------------------------------------------//
1276    // Settings Backup Commands
1277    //-----------------------------------------------------------------------//
1278
1279    /// Backup the current settings to memory.
1280    ///
1281    /// Response: [`Response::Success`].
1282    BackupSettings,
1283
1284    /// Clear settings and reset to defaults.
1285    ///
1286    /// Response:
1287    /// - [`Response::Success`] on success.
1288    /// - [`Response::Error`] on failure.
1289    ClearSettings,
1290
1291    /// Restore settings from the backup.
1292    ///
1293    /// Response: [`Response::Success`].
1294    RestoreBackupSettings,
1295
1296    /// Get the optimizer options.
1297    ///
1298    /// Response: [`Response::OptimizerOptions`].
1299    OptimizerOptions,
1300
1301    //-----------------------------------------------------------------------//
1302    // Schema Query Commands
1303    //-----------------------------------------------------------------------//
1304
1305    /// Check if a schema is loaded.
1306    ///
1307    /// Response: [`Response::Bool`].
1308    IsSchemaLoaded,
1309
1310    /// Get all definitions for a table name.
1311    ///
1312    /// Response:
1313    /// - [`Response::VecDefinition`] on success.
1314    /// - [`Response::Error`] if no schema.
1315    DefinitionsByTableName(String),
1316
1317    /// Get columns that reference a table's definition.
1318    ///
1319    /// Response:
1320    /// - [`Response::HashMapStringHashMapStringVecString`] on success.
1321    /// - [`Response::Error`] if no schema.
1322    ReferencingColumnsForDefinition(String, Definition),
1323
1324    /// Get the current schema.
1325    ///
1326    /// Response:
1327    /// - [`Response::Schema`] on success.
1328    /// - [`Response::Error`] if no schema.
1329    Schema,
1330
1331    /// Get a specific definition by table name and version.
1332    ///
1333    /// Response:
1334    /// - [`Response::Definition`] on success.
1335    /// - [`Response::Error`] if not found or no schema.
1336    DefinitionByTableNameAndVersion(String, i32),
1337
1338    /// Delete a definition by table name and version.
1339    ///
1340    /// Response: [`Response::Success`].
1341    DeleteDefinition(String, i32),
1342
1343    /// Get the processed fields from a definition (bitwise expansion, enum conversion, colour merging applied).
1344    ///
1345    /// Response: [`Response::VecField`].
1346    FieldsProcessed(Definition),
1347}
1348
1349/// This enum defines the responses (messages) you can send to the UI thread as result of a command.
1350///
1351/// Each response is named after the types of the items it carries, making them self-documenting.
1352/// For example, `VecString` returns a `Vec<String>`, and `DBRFileInfo` returns a `(DB, RFileInfo)` tuple.
1353#[derive(Debug, Serialize, Deserialize)]
1354pub enum Response {
1355    /// Generic response for situations of success where no data needs to be returned.
1356    Success,
1357
1358    /// Generic response for situations that returned an error, containing the error message.
1359    Error(String),
1360
1361    /// Response sent by the server immediately after a WebSocket connection is established.
1362    /// Contains the session ID that the client is connected to.
1363    SessionConnected(u64),
1364
1365    #[allow(dead_code)]BmdRFileInfo(Box<Bmd>, RFileInfo),
1366    AnimFragmentBattleRFileInfo(AnimFragmentBattle, RFileInfo),
1367    AnimPackRFileInfo(Vec<RFileInfo>, RFileInfo),
1368    AnimsTableRFileInfo(AnimsTable, RFileInfo),
1369    APIResponse(APIResponse),
1370    APIResponseGit(GitResponse),
1371    AtlasRFileInfo(Atlas, RFileInfo),
1372    AudioRFileInfo(Audio, RFileInfo),
1373    Bool(bool),
1374    CompressionFormat(CompressionFormat),
1375    CompressionFormatDependenciesInfo(CompressionFormat, Option<DependenciesInfo>),
1376    ContainerInfo(ContainerInfo),
1377    ContainerInfoVecRFileInfo((ContainerInfo, Vec<RFileInfo>)),
1378    StringContainerInfo(String, ContainerInfo),
1379    DataSourceStringUsizeUsize(DataSource, String, usize, usize),
1380    DBRFileInfo(DB, RFileInfo),
1381    Definition(Definition),
1382    DependenciesInfo(DependenciesInfo),
1383    Diagnostics(Diagnostics),
1384    ESFRFileInfo(ESF, RFileInfo),
1385    F32(f32),
1386    GlobalSearchVecRFileInfo(Box<GlobalSearch>, Vec<RFileInfo>),
1387    GroupFormationsRFileInfo(GroupFormations, RFileInfo),
1388    HashMapDataSourceHashMapStringRFile(HashMap<DataSource, HashMap<String, RFile>>),
1389    HashMapDataSourceHashSetContainerPath(HashMap<DataSource, HashSet<ContainerPath>>),
1390    HashMapI32TableReferences(HashMap<i32, TableReferences>),
1391    HashMapStringHashMapStringVecString(HashMap<String, HashMap<String, Vec<String>>>),
1392    HashSetString(HashSet<String>),
1393    HashSetStringHashSetString(HashSet<String>, HashSet<String>),
1394    I32(i32),
1395    I32I32(i32, i32),
1396    I32I32VecStringVecString(i32, i32, Vec<String>, Vec<String>),
1397    ImageRFileInfo(Image, RFileInfo),
1398    LocRFileInfo(Loc, RFileInfo),
1399    MatchedCombatRFileInfo(MatchedCombat, RFileInfo),
1400    Note(Note),
1401    OperationalMode(OperationalMode),
1402    OptimizerOptions(OptimizerOptions),
1403    OptionContainerPath(Option<ContainerPath>),
1404    OptionRFileInfo(Option<RFileInfo>),
1405    OptionStringStringVecString(Option<(String, String, Vec<String>)>),
1406    PackSettings(PackSettings),
1407    PackTranslation(PackTranslation),
1408    PathBuf(PathBuf),
1409    PortraitSettingsRFileInfo(PortraitSettings, RFileInfo),
1410    RFileDecoded(RFileDecoded),
1411    RigidModelRFileInfo(RigidModel, RFileInfo),
1412    Schema(Schema),
1413    String(String),
1414    StringVecContainerPath(String, Vec<ContainerPath>),
1415    StringVecPathBuf(String, Vec<PathBuf>),
1416    Text(Text),
1417    TextRFileInfo(Text, RFileInfo),
1418    UICRFileInfo(UIC, RFileInfo),
1419    UnitVariantRFileInfo(UnitVariant, RFileInfo),
1420    Unknown,
1421    VecBoolString(Vec<(bool, String)>),
1422    VecContainerPath(Vec<ContainerPath>),
1423    VecContainerPathContainerPath(Vec<(ContainerPath, ContainerPath)>),
1424    VecContainerPathOptionString(Vec<ContainerPath>, Option<String>),
1425    VecContainerPathVecContainerPath(Vec<ContainerPath>, Vec<ContainerPath>),
1426    VecContainerPathBTreeMapStringVecContainerPath(Vec<ContainerPath>, BTreeMap<String, Vec<ContainerPath>>),
1427    VecContainerPathVecContainerPathString(Vec<ContainerPath>, Vec<ContainerPath>, String),
1428    VecContainerPathVecRFileInfo(Vec<ContainerPath>, Vec<RFileInfo>),
1429    VecContainerPathVecString(Vec<ContainerPath>, Vec<String>),
1430    VecDataSourceStringStringStringUsizeUsize(Vec<(DataSource, String, String, String, usize, usize)>),
1431    VecDefinition(Vec<Definition>),
1432    VecField(Vec<Field>),
1433    VecNote(Vec<Note>),
1434    VecRFile(Vec<RFile>),
1435    VecRFileInfo(Vec<RFileInfo>),
1436    VecString(Vec<String>),
1437    VecStringTuples(Vec<(String, String)>),
1438    VecStringContainerInfo(Vec<(String, ContainerInfo)>),
1439    VecU8(Vec<u8>),
1440    VideoInfoRFileInfo(VideoInfo, RFileInfo),
1441    VMDRFileInfo(Text, RFileInfo),
1442    WSModelRFileInfo(Text, RFileInfo),
1443
1444    /// All settings in one response (for batch loading).
1445    SettingsAll(SettingsSnapshot),
1446}