Mountain/Binary/IPC/
PerformanceStatsCommand.rs

1//! # PerformanceStatsCommand
2//!
3//! Retrieves application performance statistics.
4//!
5//! ## RESPONSIBILITIES
6//!
7//! ### Performance Monitoring
8//! - Get performance metrics
9//! - Report CPU/memory usage
10//! - Return operational statistics
11//!
12//! ## ARCHITECTURAL ROLE
13//!
14//! ### Position in Mountain
15//! - IPC wrapper command in Binary subsystem
16//! - Performance monitoring endpoint
17//!
18//! ### Dependencies
19//! - crate::IPC::AdvancedFeatures: Performance tracking
20//! - tauri: IPC framework
21//! - serde_json: JSON serialization
22//!
23//! ### Dependents
24//! - Wind frontend: Queries performance stats
25//! - DevTools: Performance monitoring
26//!
27//! ## SECURITY
28//!
29//! ### Considerations
30//! - Stats are read-only, no security impact
31//! - Avoid exposing sensitive paths in stats
32//!
33//! ## PERFORMANCE
34//!
35//! ### Considerations
36//! - Stats collection should be lightweight
37//! - Sampling rate affects accuracy vs overhead
38
39use serde_json::{Value, to_value};
40use tauri::AppHandle;
41
42/// Get performance stats.
43///
44/// Retrieves current performance statistics for monitoring.
45///
46/// # Arguments
47///
48/// * `app_handle` - Tauri application handle
49///
50/// # Returns
51///
52/// Returns performance stats JSON, or an error string.
53///
54/// # Errors
55///
56/// Returns an error if stats cannot be collected.
57#[tauri::command]
58pub async fn MountainGetPerformanceStats(app_handle:AppHandle) -> Result<Value, String> {
59	let stats = crate::IPC::AdvancedFeatures::mountain_get_performance_stats(app_handle).await?;
60	to_value(&stats).map_err(|e| format!("Failed to serialize performance stats: {}", e))
61}