Skip to main content

write_string_atomic

Function write_string_atomic 

Source
pub fn write_string_atomic<P: AsRef<Path>>(
    path: P,
    contents: &str,
) -> Result<()>
Expand description

Writes contents to path atomically (temp file in the same dir, fsync, rename), so a concurrent reader never observes a partial file.

The string counterpart of write_json_atomic, used to persist non-JSON text such as the ~/.vct/config.toml settings file.

ยงErrors

Returns an error if the parent directory cannot be created, the temp file cannot be written, or the final rename fails.