pub fn write_json_file_atomic<T: Serialize>(
path: impl AsRef<Path>,
data: &T,
) -> Result<(), JsonError>Expand description
Serialize and write JSON to the provided path by writing to a temporary file in the same directory, then atomically renaming it over the destination. Unlike a truncate-then-write, another process can never observe an empty or partially written file, even if this process is killed mid-write. https://github.com/moonrepo/proto/issues/1057