Expand description
Atomic file I/O utilities for concurrency-safe cache operations.
This module provides:
- Atomic writes via temp-file + rename to prevent partial/corrupt files.
- Advisory file locking for coordinating concurrent access to cache directories.
§Concurrency Guarantees
- A reader will never see a partially written file.
- Concurrent writers to the same path will not interleave bytes; the last rename wins, producing one complete file.
- Advisory locks coordinate cache-directory operations across processes.
§Cross-Platform Notes
- On POSIX systems,
rename(2)is atomic within the same filesystem. - On Windows,
std::fs::renameusesMoveFileExwithMOVEFILE_REPLACE_EXISTING, which is atomic for same-volume renames.
Structs§
- DirLock
- An advisory file lock scoped to a directory.
Functions§
- atomic_
write - Write
datatopathatomically by writing to a temporary sibling file and then renaming it into place. - atomic_
write_ sync - Synchronous version of
atomic_writefor use in contexts that cannot use async (e.g., theFileSystemtrait).