Mountain/Binary/IPC/
CacheStatsCommand.rs

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