Skip to main content

load_or_create_with

Function load_or_create_with 

Source
pub fn load_or_create_with<F>(path: &Path, create: F) -> Result<Vec<u8>>
where F: FnOnce() -> Vec<u8>,
Expand description

Load a private regular file, or create it once from create.

Creation uses a temporary file beside path. Its contents are synchronized before a no-clobber commit. The containing directory is synchronized where supported. A concurrent winner’s bytes are loaded and returned.

On Unix, existing files are restricted to mode 0600 before reading. The final path is opened without following a symbolic link. Other platforms retain the operating system’s inherited access controls.

§Errors

Returns a contextual error when the parent cannot be created. Non-regular entries and file operation failures are also reported.