fn apply_settings_key(
current: &Settings,
key: &str,
value: Value,
) -> Result<Settings, String>Expand description
Merge a single key/value override into current and return the
resulting Settings, ready to store.
Pure (no locks, no runtime), so the JSON round-trip + clamp is
unit-testable without driving the production AppHandle<Wry> IPC path.
Serialises current to JSON, validates the key exists, swaps in
value, deserialises back, and runs clamp() — the same normalisation
the GUI update_settings command applies. Without it the IPC/CLI path
could persist out-of-range values the GUI forbids (e.g. a 0s interval
that makes a break fire every tick) and skip custom_css/fixed-time
sanitisation. clamp() rebuilds the #[serde(skip)] derived cache as
its final step, so the wholesale-deserialise’s empty cache is repopulated.
Errors are the user-facing strings the IPC handler returns verbatim.