Function open_file

Source
pub async fn open_file(
    filepath: &PathBuf,
    expected_identifier: &str,
    latest_version: u8,
    upgrades: &Vec<Upgrade>,
) -> Result<VersionedFile, Error>
Expand description

open_file will open a versioned file.

If the file does not yet exist, a new VersionedFile will be created containing the latest_version and the provided identifier in the header. If the file exists but is an older version, the update_paths will be used to update the file to the latest version.

An error will be returned if the file does exist and has the wrong identifier, or if the file has a version that is higher than ‘latest_version’, or if the upgrades do not provide a valid path from the current version of the file to the latest version.