Skip to main content

write_file_atomic

Function write_file_atomic 

Source
pub fn write_file_atomic(
    path: &Utf8Path,
    content: &str,
) -> Result<AtomicWriteResult>
Expand description

Atomically write content to a file using temp file + fsync + rename

This implements FR-FS-001 through FR-FS-005:

  • FR-FS-001: Write to temporary file first, fsync, then atomically rename
  • FR-FS-002: Windows rename retry with bounded exponential backoff (≤ 250ms)
  • FR-FS-003: Track rename_retry_count in warnings
  • FR-FS-004: UTF-8 encoding with LF line endings
  • FR-FS-005: Cross-filesystem fallback (copy→fsync→replace)