Skip to content

Commit

Permalink
Update CanisterInstallMode signature
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Oct 30, 2024
1 parent 13d01ed commit d0a20b9
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/ic-cdk/src/api/management_canister/main/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ pub enum CanisterInstallMode {
Reinstall,
/// Upgrade an existing canister.
#[serde(rename = "upgrade")]
Upgrade(Option<SkipPreUpgrade>),
Upgrade(Option<UpgradeFlags>),
}

/// If set to true, the pre_upgrade step will be skipped during the canister upgrade
/// Flags for canister installation with [`CanisterInstallMode::Upgrade`].
#[derive(
CandidType,
Serialize,
Expand All @@ -209,7 +209,37 @@ pub enum CanisterInstallMode {
Copy,
Default,
)]
pub struct SkipPreUpgrade(pub Option<bool>);
pub struct UpgradeFlags {
/// If set to `true`, the `pre_upgrade` step will be skipped during the canister upgrade
pub skip_pre_upgrade: Option<bool>,
/// If set to `Keep`, the WASM heap memory will be preserved instead of cleared.
pub wasm_memory_persistence: Option<WasmPersistenceMode>,
}

/// WASM memory persistence setting for [`UpgradeFlags`].
#[derive(
CandidType,
Serialize,
Deserialize,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Clone,
Copy,
Default,
)]
pub enum WasmPersistenceMode {
/// Preserve heap memory (only officially supported by Motoko)
#[serde(rename = "keep")]
Keep,
/// Clear heap memory
#[serde(rename = "replace")]
#[default]
Replace,
}

/// WASM module.
pub type WasmModule = Vec<u8>;
Expand Down

0 comments on commit d0a20b9

Please sign in to comment.