saluki_core/diagnostic/
event.rs

1//! Abstract diagnostic events.
2
3/// Structured detail describing the nature of a [`DiagnosticEvent`].
4#[derive(Clone, Debug, Eq, PartialEq)]
5#[non_exhaustive]
6pub enum DiagnosticDetails {
7    /// The configured API key was rejected as invalid.
8    InvalidApiKey,
9}
10
11/// An abstract, point-in-time diagnostic event emitted by a subsystem.
12///
13/// An event pairs a human-readable message with a structured [`DiagnosticDetails`] value describing what occurred.
14#[derive(Clone, Debug, Eq, PartialEq)]
15pub struct DiagnosticEvent {
16    message: String,
17    details: DiagnosticDetails,
18}
19
20impl DiagnosticEvent {
21    /// Creates a new diagnostic event with the given message and structured detail.
22    pub fn new(message: impl Into<String>, details: DiagnosticDetails) -> Self {
23        Self {
24            message: message.into(),
25            details,
26        }
27    }
28
29    /// Returns the human-readable message.
30    pub fn message(&self) -> &str {
31        &self.message
32    }
33
34    /// Returns the structured detail.
35    pub fn details(&self) -> &DiagnosticDetails {
36        &self.details
37    }
38}