rpfm_ipc/lib.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//! # RPFM IPC - Inter-Process Communication Protocol
12//!
13//! This crate defines the IPC protocol used for communication between the RPFM frontend
14//! and the backend server (`rpfm_server`). It provides type-safe message definitions that ensure
15//! consistent communication between the two processes.
16//!
17//! ## Protocol Overview
18//!
19//! The communication follows a request-response pattern over WebSocket connections:
20//!
21//! 1. The frontend creates a [`messages::Message<Command>`] with a unique ID
22//! 2. The message is serialized to JSON and sent over WebSocket to the server
23//! 3. The server processes the command and sends back a [`messages::Message<Response>`]
24//! 4. The frontend matches the response ID to the original request
25//!
26//! This ID correlation mechanism enables asynchronous, non-blocking communication where multiple
27//! requests can be in flight simultaneously.
28//!
29//! ## Modules
30//!
31//! - [`messages`]: Core protocol definitions including [`messages::Command`], [`messages::Response`],
32//! and the [`messages::Message`] wrapper.
33//! - [`helpers`]: Data structures for marshalling complex data between UI and server, including
34//! [`helpers::ContainerInfo`], [`helpers::RFileInfo`], and [`helpers::DataSource`].
35//!
36//! ## Usage
37//!
38//! This crate is not intended for standalone use. It serves as a shared dependency between
39//! `rpfm_server` and `rpfm_ui`, providing the common language they need to communicate.
40//!
41//! ### Example Message Flow
42//!
43//! ```ignore
44//! // Frontend creates a command
45//! let command = Message {
46//! id: 1,
47//! data: Command::OpenPackFiles(vec![PathBuf::from("/path/to/pack.pack")]),
48//! };
49//!
50//! // Serialize and send over WebSocket...
51//!
52//! // Server responds with matching ID
53//! let response = Message {
54//! id: 1, // Same ID as the request
55//! data: Response::ContainerInfo(container_info),
56//! };
57//! ```
58
59pub mod helpers;
60pub mod messages;
61pub mod settings_keys;