Skip to main content

Module fields

Module fields 

Source
Expand description

Single source of truth for the set of displayable fields and their output strata.

Historically the field list was hand-duplicated across main.rs (collection allow-lists and the generated config template), display.rs (display allow-lists), config.rs (DEFAULT_FIELDS_BLOCK), plus README.md and docs/retch.1.md. Every copy was a raw list of &str literals with no shared definition, so adding or renaming a field risked silent drift — a field could be collected but never displayed (or vice versa), or documented inconsistently.

This module replaces the in-code copies with one [FIELDS] table. main.rs and display.rs derive their per-strata allow-lists from fields_for, and both config-generation paths derive the commented fields = [...] block from config_fields_block. The documentation copies (README.md, docs/retch.1.md) can’t be generated from Rust, so a guardrail test in tests/cli_tests.rs asserts every [FIELDS] key appears in both, turning future drift into a test failure instead of a silent bug.

Enums§

Mode
Output verbosity mode, ordered from least to most verbose.

Functions§

all_keys
Returns every field key, in table order.
config_fields_block
Generates the commented fields = [...] block for the default config file.
fields_for
Returns the ordered list of field keys visible in the given Mode.