pub async fn open_file(
filepath: &PathBuf,
expected_identifier: &str,
latest_version: u8,
upgrades: &Vec<Upgrade>,
open_settings: OpenSettings,
) -> Result<AtomicFile, Error>
Expand description
open_file will open an atomic file, using the backup of the file if the checksum fails. If ‘create_if_not_exists’ is set to ‘true’, a new file empty file will be created if a file does not already exist.
If the version of the file on-disk is outdated, the upgrades will be used in a chain to upgrade the file to the latest version. If no valid path exists from the file’s current version to the latest version, an error will be returned.
An error will also be returned if the file has the wrong identifier, or if it is determined that both the file and its backup are corrupt. Both files should only be corrupt in the event of significant physical damage to the storage device.