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
spdrcommand-line interface. - Decode
Args - Arguments to
spdr decode. - Decode
Results - The per-section decode results, each section independently
Okor a typedDecodeError. Borrows the input image for the manufacturing part number. - Lint
Args - Arguments to
spdr lint. MirrorsDecodeArgs: the same file input and the same--jsonswitch. - Lint
Report - The collected lint findings for an image, plus whether the base configuration
decoded. Mirrors
DecodeResultsfor the lint path: produced once bylint_report, rendered by the pure render functions, and used to compute the exit code.
Enums§
- Commands
- The
spdrsubcommands.decodeprints the typed decode;lintruns 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:
1if anyErrororWarningis present,0if there are none or onlyInfoadvisories. The operational2(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: valueplain text. Pure and allocation-bounded; a failed section shows its error instead of fabricated fields. Never panics (no indexing, nounwrapon 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 stablecode, a humanmessage, and its structuredfields(the coreFinding’s serde representation, unwrapped to just the variant’s fields, sincecodealready 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.