Skip to main content

write_with

Function write_with 

Source
pub fn write_with(
    path: impl AsRef<Path>,
    graph: &NirGraph,
    opts: &WriteOptions,
) -> Result<()>
Expand description

Write a NIR graph to a .nir (HDF5) path with explicit options.

Uses the same atomic staging and replacement protocol as write().

Symlink handling: When path is a symlink, the atomic rename replaces the symlink itself rather than updating its target. To update the target file, pass a resolved path: use std::fs::canonicalize for a fully resolved absolute path, or join a relative std::fs::read_link result with the symlink’s parent before writing (raw read_link alone is not enough when the stored target is relative).

ACL preservation: Only basic Unix permission bits (mode) are preserved from an existing destination. POSIX ACLs and Windows DACLs are not copied to the new inode. If the destination is ACL-protected, the replacement may change who can access it.

Multi-user destination directories: Staging is hardened against parent directory rename races when the destination parent is shared and non-sticky (see write()). If no safe staging base can be found (sticky temp owned by current user, or private per-user directories with verified ownership ancestry), the write fails. Cross-device promotion is also rejected when the destination parent is shared and non-sticky to prevent path-swap vulnerabilities during local staging. The final rename into a multi-user non-sticky parent still cannot be made fully race-free while HDF5 requires a path reopen; use private directories when untrusted local users can write the parent.

§Errors