Skip to main content

Mountain/IPC/StatusReporter/
mountain_get_ipc_status_history.rs

1//! `mountain_get_ipc_status_history` Tauri command - returns
2//! the last-100 ring buffer of `IPCStatusReport::Struct`.
3
4use tauri::Manager;
5
6use crate::{IPC::StatusReporter::Reporter::Struct as Reporter, dev_log};
7
8#[tauri::command]
9pub async fn mountain_get_ipc_status_history(app_handle:tauri::AppHandle) -> Result<serde_json::Value, String> {
10	dev_log!("lifecycle", "Tauri command: get_ipc_status_history");
11
12	if let Some(reporter) = app_handle.try_state::<Reporter>() {
13		reporter
14			.get_status_history()
15			.map(|history| serde_json::to_value(history).unwrap_or(serde_json::Value::Null))
16	} else {
17		Err("StatusReporter not found in application state".to_string())
18	}
19}