Skip to main content

Crate spdr_cli

Crate spdr_cli 

Source
Expand description

spdr-cli library · the decode-and-render core behind the spdr binary.

Split out from main.rs so render_human and render_json are pure, snapshot-testable functions and the decode pipeline can be property-tested without spawning a subprocess. The binary is a thin wrapper over run.

The CLI presents exactly what the library decodes, with no inflated labels: the JEDEC base timings are the guaranteed fallback, and the rated DDR5 speed is shown separately in the vendor-profiles section (XMP 3.0 / EXPO), each anchored by its section CRC. The base CRC is presented as a reported status, not a verdict. A section that fails to decode is shown with its error rather than fabricated output.

Alongside decode, the lint subcommand runs the semantic linter (the validation-beyond-CRC pillar) and renders its findings, with its own exit-code contract: 0 when clean or only Info advisories, 1 when a Warning or Error finding is present, 2 when the file could not be read. Its renderers (render_lint_human, render_lint_json) are pure like the decode renderers, so they are golden-tested without spawning the process.

Structs§

Cli
The spdr command-line interface.
DecodeArgs
Arguments to spdr decode.
DecodeResults
The per-section decode results, each section independently Ok or a typed DecodeError. Borrows the input image for the manufacturing part number.
LintArgs
Arguments to spdr lint. Mirrors DecodeArgs: the same file input and the same --json switch.
LintReport
The collected lint findings for an image, plus whether the base configuration decoded. Mirrors DecodeResults for the lint path: produced once by lint_report, rendered by the pure render functions, and used to compute the exit code.

Enums§

Commands
The spdr subcommands. decode prints the typed decode; lint runs the semantic linter and reports its findings. Each subcommand defines its own exit-code contract, so the two do not collide.

Functions§

decode
Run every library decoder over bytes, holding the per-section results. No decoder can panic on malformed input (Phase 6), so this never panics.
lint_exit_code
The lint exit code computed from the findings: 1 if any Error or Warning is present, 0 if there are none or only Info advisories. The operational 2 (unreadable file or bad arguments) is handled in [run_lint] and by clap, never here.
lint_report
Run the core linter over bytes, collecting and ordering the findings. Pure and panic-free (the core lint never panics). Findings are ordered by severity (errors first) then by code, so the renders are deterministic.
render_human
Render the decode as sectioned, aligned key: value plain text. Pure and allocation-bounded; a failed section shows its error instead of fabricated fields. Never panics (no indexing, no unwrap on decoded data).
render_json
Render the decode as a JSON object keyed by section. Each value is the serde-serialized library type; a failed section carries an error indicator, so the object always has all five keys and stays valid JSON.
render_lint_human
Render the lint report as readable text: an optional limited-coverage note, a summary line, then one block per finding (severity and code, then the message). Pure and allocation-bounded; never panics.
render_lint_json
Render the lint report as a JSON array of findings (an empty array when there are none). Each finding carries its lowercase severity, its stable code, a human message, and its structured fields (the core Finding’s serde representation, unwrapped to just the variant’s fields, since code already names the rule).
run
Parse arguments and run the chosen subcommand, returning the process exit code. clap handles --help/--version (exit 0) and usage errors (exit 2) itself before this returns.