Skip to main content

write

Function write 

Source
pub fn write(
    target: &Path,
    ops: &[Op],
    options: &WriteOptions,
) -> Result<WriteReceipt>
Expand description

Apply typed ops to target and publish the result atomically.

A leading CreateDocx or CreateXlsx makes a new file (the target must not exist unless options.overwrite); any other first op edits the existing file. Ops apply in order to one in-memory document; nothing touches the disk until every op has succeeded and the result has been re-detected as the same format. An edit then rechecks the target’s SHA-256 (against options.expect_sha256 when given, always against the bytes this call started from) as the last step before the rename, so a file changed meanwhile is never overwritten (source_changed). The receipt lists everything the edit could not keep.