Type Definition atomic_file::UpgradeFunc
source · pub type UpgradeFunc = fn(data: Vec<u8>, initial_version: u8, upgraded_version: u8) -> Result<Vec<u8>, Error>;
Expand description
UpgradeFunc defines the signature for a function that can be used to upgrade an AtomicFile. The UpgradeFunc function will receive the file data that needs to be upgraded along with the intended initial version and final version that is expected from the upgrade.
We pass in the initial version and final version as arguments to provide an extra level of redundancy and to prevent mistakes when copy-pasting upgrades, as an incorrect upgrade could corrupt user data.