Skip to main content

Module render

Module render 

Source
Expand description

Output rendering: the one place JSON is serialized, so every command’s --json twin is byte-deterministic the same way.

Reports are always serialized through serde_json::Value, whose map is a BTreeMap (serde_json’s default, no preserve_order) — so keys sort alphabetically regardless of struct field order, and an agent can diff two runs and see only real change (dx-spec §5, “determinism as courtesy”).

Functions§

emit
Print a Rendered result to the right stream and return its exit code. json selects the machine twin; otherwise the human prose is printed. Errors and diagnostics (Rendered::to_stderr) go to stderr regardless.
json_string
Render a serde_json::Value to the exact bytes the --json twin prints.
to_json
Serialize any report to canonical JSON: sorted keys, pretty-printed, one trailing newline. Panics only on a report that cannot serialize, which is a programming error (all report structs are plain Serialize).