pub struct SelfDiagnosisEngine { /* private fields */ }Expand description
Engine for tracking diagnostic messages with numeric codes, severity, and auto-timeout.
Thread-safe. Implements StatusSource for integration with StatusEngine.
Implementations§
Source§impl SelfDiagnosisEngine
impl SelfDiagnosisEngine
pub fn new() -> Self
Sourcepub fn with_status_name(status_name: impl Into<String>) -> Self
pub fn with_status_name(status_name: impl Into<String>) -> Self
Like new, but with a custom StatusSource node name
(consumers compose their own status trees and need stable keys; the
historical default “RunTimeTests” stems from the ToolScope lineage).
Sourcepub fn notify(&self, code: u16, message: &str, severity: Severity)
pub fn notify(&self, code: u16, message: &str, severity: Severity)
Report a diagnostic message. Duplicate codes are ignored (first wins).
Sourcepub fn notify_with_timeout(
&self,
code: u16,
message: &str,
severity: Severity,
timeout: Duration,
)
pub fn notify_with_timeout( &self, code: u16, message: &str, severity: Severity, timeout: Duration, )
Report a diagnostic message with auto-timeout.
Sourcepub fn notify_keyed(
&self,
code: u16,
parts: Vec<MessagePart>,
fallback: &str,
severity: Severity,
)
pub fn notify_keyed( &self, code: u16, parts: Vec<MessagePart>, fallback: &str, severity: Severity, )
Report a message the UI can translate: parts carry text keys and
placeholder values, fallback is the plain text (logs, heartbeat,
UIs without the keys). Duplicate codes are ignored (first wins).
Sourcepub fn notify_keyed_with_timeout(
&self,
code: u16,
parts: Vec<MessagePart>,
fallback: &str,
severity: Severity,
timeout: Duration,
)
pub fn notify_keyed_with_timeout( &self, code: u16, parts: Vec<MessagePart>, fallback: &str, severity: Severity, timeout: Duration, )
Like notify_keyed, with auto-timeout.
Sourcepub fn get_messages(&self) -> Vec<DiagnosisMessage>
pub fn get_messages(&self) -> Vec<DiagnosisMessage>
Get all active messages (expired ones are pruned).
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Returns true if any active message has Error severity.
Sourcepub fn on_change<F: Fn() + Send + Sync + 'static>(&self, callback: F)
pub fn on_change<F: Fn() + Send + Sync + 'static>(&self, callback: F)
Register an observer callback that is called on every change (notify/clear).
Sourcepub fn reset_for_testing(&self)
pub fn reset_for_testing(&self)
Reset for testing.