Attribute Macro ic_cdk::pre_upgrade
source · #[pre_upgrade]
Expand description
Register the canister_pre_upgrade
entry point of a canister.
This attribute macro will export the function canister_pre_upgrade
in the canister module.
The function under this attribute must have no return value.
Each canister can only have one canister_pre_upgrade
entry point.
Example
#[pre_upgrade]
fn pre_upgrade_function() {
// ...
}
You can specify a guard function to be executed before the pre_upgrade function. When the guard function returns an error, the pre_upgrade function will not proceed.
fn guard_function() -> Result<(), String> {
// ...
}
#[pre_upgrade(guard = "guard_function")]
fn pre_upgrade_function() {
// ...
}