helm_schema_k8s/diagnostic/format_json.rs
1use super::diagnostic::Diagnostic;
2
3/// Serialize a [`Diagnostic`] to a single-line JSON string. Tagged
4/// discriminated union (`#[serde(tag = "type")]`) keeps the shape
5/// stable across versions. Returns `None` only on JSON serialization
6/// failure, which should never happen for the variants we own.
7#[must_use]
8pub fn format_diagnostic_json(diagnostic: &Diagnostic) -> Option<String> {
9 serde_json::to_string(diagnostic).ok()
10}