Skip to main content

Mountain/Binary/IPC/
StatusGetCommand.rs

1//! # StatusGetCommand
2//!
3//! Retrieves the current Mountain IPC status.
4//!
5//! ## RESPONSIBILITIES
6//!
7//! ### Status Query
8//! - Get current IPC server status
9//! - Query active connections and message metrics
10//! - Return structured status information
11//! - Handle error conditions gracefully
12//!
13//! ## ARCHITECTURAL ROLE
14//!
15//! ### Position in Mountain
16//! - IPC command in Binary subsystem
17//! - Diagnostic endpoint for IPC health
18//!
19//! ### Dependencies
20//! - crate::IPC::TauriIPCServer: Status retrieval
21//! - tauri: IPC framework
22//! - serde_json: JSON serialization
23//!
24//! ### Dependents
25//! - Wind frontend: Queries status for diagnostics
26//! - Development tools: Monitor IPC health
27//!
28//! ## SECURITY
29//!
30//! ### Considerations
31//! - Status information is read-only, no modification
32//! - Avoid exposing sensitive connection details
33//!
34//! ## PERFORMANCE
35//!
36//! ### Considerations
37//! - Status query is typically fast, in-memory operation
38//! - Consider rate limiting if called frequently
39
40use serde_json::Value;
41use tauri::AppHandle;
42
43use crate::dev_log;
44
45/// Get Mountain IPC status.
46///
47/// This command retrieves the current status of the IPC server including
48/// connection information, message statistics, and operational state.
49///
50/// # Arguments
51///
52/// * `app_handle` - Tauri application handle
53///
54/// # Returns
55///
56/// Returns a JSON object containing the IPC status on success,
57/// or an error string on failure.
58///
59/// # Errors
60///
61/// Returns an error if:
62/// - Status cannot be retrieved from IPC server
63#[tauri::command]
64pub async fn MountainIPCGetStatus(app_handle:AppHandle) -> Result<Value, String> {
65	let Status = crate::IPC::TauriIPCServer::mountain_ipc_get_status(app_handle)
66		.await
67		.map_err(|Error| {
68			dev_log!("ipc", "error: [IPC] [Command] Failed to get IPC status: {}", Error);
69			Error.to_string()
70		})?;
71	Ok(serde_json::to_value(Status).map_err(|e| e.to_string())?)
72}