Expand description
Atomic file write pipeline: tempfile, fsync, rename, fsync directory.
Workload: I/O-bound (single-file durable write + optional backup/journal).
Parallelism: none inside one write (ordered rename/fsync contract). Multi-file
callers (backup, batch, delete) fan out with rayon around this module.
Three write strategies are available, selected automatically:
WriteStrategy::Rename— classic tempfile +rename(2)(atomic, but destroys hardlinks and inode identity).WriteStrategy::InPlace—ftruncate(0) + pwrite + fsync_dataon the existing file descriptor (preserves inode and hardlinks, but NOT atomic against a crash between truncate and write).WriteStrategy::CopyBack— like InPlace but with a journal sidecar for crash recovery; slowest but most durable. (Reserved for v0.1.13.)
The default policy is auto-detect: hardlinks and symlinks trigger
InPlace automatically, regular files use Rename. Pass
WriteStrategy::Rename explicitly via the strategy field of
AtomicWriteOptions to force the legacy behavior.
Structs§
- Atomic
Write Options - Configuration for an atomic write operation.
- Write
Result - Result metadata returned after a successful atomic write.
Enums§
- Write
Strategy - Write strategy selected by the atomic pipeline.
Functions§
- atomic_
write - Write content atomically via tempfile, fsync, and rename.
- rfc3339_
now - Return the current UTC time as an RFC 3339 string (e.g.
2024-01-15T14:30:22Z).