Skip to main content

futu_core/
diagnostic.rs

1//! Shared diagnostic decision rows for operator-facing readiness/capability reports.
2//!
3//! Keep this type deliberately small: public surfaces can add local detail fields, but
4//! the first row of "can I use this path, why, and what should I do next" should stay
5//! uniform across CLI / REST / MCP / gateway diagnostics.
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct DiagnosticDecision {
11    pub topic: String,
12    pub allowed: bool,
13    pub reason: String,
14    pub action: String,
15    pub source: String,
16    pub freshness: String,
17}
18
19impl DiagnosticDecision {
20    pub fn allowed(
21        topic: impl Into<String>,
22        reason: impl Into<String>,
23        source: impl Into<String>,
24        freshness: impl Into<String>,
25    ) -> Self {
26        Self {
27            topic: topic.into(),
28            allowed: true,
29            reason: reason.into(),
30            action: "no action needed".to_string(),
31            source: source.into(),
32            freshness: freshness.into(),
33        }
34    }
35
36    pub fn blocked(
37        topic: impl Into<String>,
38        reason: impl Into<String>,
39        action: impl Into<String>,
40        source: impl Into<String>,
41        freshness: impl Into<String>,
42    ) -> Self {
43        Self {
44            topic: topic.into(),
45            allowed: false,
46            reason: reason.into(),
47            action: action.into(),
48            source: source.into(),
49            freshness: freshness.into(),
50        }
51    }
52}