Skip to main content

Module profile_bridge

Module profile_bridge 

Source
Expand description

Conversion helpers between rtcom_config’s string-based Profile and rtcom_core’s typed SerialConfig / LineEndingConfig.

The profile layer persists each field as a stable TOML string ("none", "even", "crlf", …) so hand-edited files survive refactors in rtcom-core’s enums. This module bridges the two representations in both directions:

Unknown strings fall through to sensible defaults rather than erroring: a hand-edited parity = "quantum" must never crash rtcom.

Both rtcom-cli (at startup) and rtcom-tui::run (when applying DialogAction::ReadProfile or writing back on ApplyAndSave) lean on these helpers, which is why they live in the shared rtcom-tui crate.

Functions§

line_ending_config_to_section
Project a runtime LineEndingConfig into its TOML-facing LineEndingsSection representation (used when persisting on DialogAction::ApplyLineEndingsAndSave).
line_endings_from_profile
Pull the three line-ending mappers out of a profile’s [line_endings] section. Unknown strings fall through to LineEnding::None.
parse_line_ending
Parse a profile-string line-ending rule into LineEnding. Unknown strings fall through to LineEnding::None.
serial_config_to_section
Project a runtime SerialConfig back into its TOML-facing SerialSection representation (used when persisting on --save or DialogAction::ApplyAndSave).
serial_section_to_config
Project a profile [serial] section into a runtime SerialConfig.