Skip to main content

save

Function save 

Source
pub fn save(
    path: impl AsRef<Path>,
    schema_version: u32,
    payload: &[u8],
    options: SaveOptions,
) -> Result<(), SaveError>
Expand description

Writes a validated container to a unique sibling, then replaces the name. The destination is never truncated. Parent directories must already exist. Linux durable writes sync the file before rename and the parent after it. Failures before rename preserve the destination; rename errors are reported as ambiguous, and a directory-sync error reports an already-installed save. Check SaveError::commit_state before deciding recovery. Concurrent saves use unique temporaries; last replacement wins, without game-state locking. Temporary cleanup is best effort on error/unwind; process crashes can leave uncommitted siblings. Unix files use mode 0600; old metadata is not copied.