Skip to main content

spatialrust_runtime/
diagnostics.rs

1//! Failure diagnostics codes.
2
3/// Machine-readable diagnostic code.
4#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5pub struct DiagnosticCode(pub String);
6
7/// Structured failure diagnostic.
8#[derive(Clone, Debug, PartialEq, Eq)]
9pub struct FailureDiagnostic {
10    /// Diagnostic code.
11    pub code: DiagnosticCode,
12    /// Human-readable summary.
13    pub summary: String,
14    /// Optional remediation hint.
15    pub remediation: Option<String>,
16}
17
18impl FailureDiagnostic {
19    /// Creates a diagnostic.
20    #[must_use]
21    pub fn new(
22        code: impl Into<String>,
23        summary: impl Into<String>,
24        remediation: Option<String>,
25    ) -> Self {
26        Self { code: DiagnosticCode(code.into()), summary: summary.into(), remediation }
27    }
28}