pub fn save(state: &Value) -> Result<(), String>Expand description
Write the state file, creating its directory and restricting it to its owner.
Atomic: written beside the target and renamed over it, so a reader never sees a
half-written file. It used to truncate and write in place, and a concurrent
load() that parsed the torn text fell back to an empty document, which the next
save then wrote out, erasing every cursor and cooldown on the machine.