Skip to main content

write_to_target

Function write_to_target 

Source
pub fn write_to_target(
    content: &[u8],
    target: &OutputTarget,
    overwrite: bool,
) -> Result<(), OutputError>
Expand description

Write output to target (stdout or file) with atomic file writes

For file targets, this uses atomic write semantics:

  1. Write to a temporary file in the same directory
  2. Sync to disk for durability
  3. Rename to final path (atomic on POSIX systems)

§Arguments

  • content - The bytes to write
  • target - Where to write (stdout or file path)
  • overwrite - If true, overwrite existing files; if false, error on existing

§Errors

Returns OutputError on I/O failures, missing directories, or file exists conflicts