Skip to main content

emit_success_with_warnings

Function emit_success_with_warnings 

Source
pub fn emit_success_with_warnings<T: Serialize>(
    mode: OutputMode,
    command: &str,
    data: T,
    warnings: Vec<String>,
)
Expand description

Emit a success envelope with optional non-fatal warnings attached.

Behaves like emit_success in OutputMode::Text (no-op) and in OutputMode::Json writes a JSON envelope whose warnings field is set to Some(warnings) when the supplied vector is non-empty, or None (omitted via skip_serializing_if) when the vector is empty. This keeps the JSON document byte-equivalent to the no-warnings shape for callers that pass in an empty list.