Skip to main content

move_setting

Function move_setting 

Source
pub fn move_setting(
    store: &Store,
    setting: &str,
    label: &str,
    current: Option<&str>,
    write: impl FnOnce(Map<String, Value>) -> Result<(), String>,
) -> Result<Option<String>, String>
Expand description

Moves a key that sits in settings.json as plain text into the Vault: keeps it as an api-key entry labelled label, then has write replace the setting with its vault:<id> reference and set <setting>Moved (so Settings can say so once). current is the setting’s value as the file has it. Returns the new entry’s id, or None when there was nothing to move (unset, blank, or already a reference). Whether it already ran is read from the value alone, never from a marker. When write fails the new entry is deleted again and the plain key stays where it was, so a later start tries again and nothing is kept twice.