pub fn write_string_atomic(path: &Path, contents: &str) -> Result<()>Expand description
Writes contents to path via a uniquely-named temp file then renames it
into place. On Unix the rename is atomic, the file is created 0600, and
newly-created parent directories are best-effort restricted to 0700.
Pre-existing parent directories are left unchanged so callers that write
into established locations (e.g. $HOME) do not alter their permissions.
On Windows the rename replaces an existing destination but is not
crash-atomic.
Blocking: this function uses synchronous filesystem I/O. Call it from
within tokio::task::spawn_blocking when used in an async context to
avoid stalling the executor.
ยงErrors
Returns an error when the directory cannot be created or the write/rename fails.