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
NirError::MissingNode/NirError::DuplicateEdge/NirError::InvalidGraphif the graph does not validate, if a node name or metadata key is not a legal HDF5 link name (seewire::check_link_name), if a string payload / edge endpoint contains a NUL byte, if aConv2d.input_shapeis not a length-2 pair, or if it holds a value the wire format cannot carry back unchanged (a nested graph version, or a rank-0 metadata tensor)NirError::Ioif the file cannot be created or a dataset cannot be writtenNirError::Unimplementedif thehdf5feature is off