ic-backup 0.63.2

Host-side snapshot backup and same-release recovery for Internet Computer canisters
Documentation
//! Bounded status projection with separately metered skipped metadata.
use super::{IcCanisterStatusInfo, IcLifecycleReplyError, MAX_IC_LIFECYCLE_REPLY_BYTES};
use crate::model::{
    control_authority::{ControllerSet, MAX_CONTROLLERS},
    ic_candid::BoundedVec,
};
use ic_platform::{
    Principal,
    candid_codec::decoder::{Limits, decode_one_with_skip_limit},
    management_canister_types::CanisterStatusType,
};
struct WireStatus {
    status: CanisterStatusType,
    settings: WireSettings,
}
struct WireSettings {
    controllers: BoundedVec<Principal, MAX_CONTROLLERS>,
}
ic_platform::candid_record!(WireStatus {
    100_394_802 => status: CanisterStatusType,
    2_336_062_691 => settings: WireSettings,
});
ic_platform::candid_record!(WireSettings {
    570_880_087 => controllers: BoundedVec<Principal, MAX_CONTROLLERS>,
});

pub(super) fn status(bytes: &[u8]) -> Result<IcCanisterStatusInfo, IcLifecycleReplyError> {
    let value: WireStatus = decode_one_with_skip_limit(
        bytes,
        Limits {
            bytes: MAX_IC_LIFECYCLE_REPLY_BYTES,
            header: 64 * 1024,
            types: 64,
            work: 2 * 1024 * 1024,
            allocation: 2 * 1024 * 1024,
        },
        64 * 1024,
    )
    .map_err(|_| IcLifecycleReplyError::InvalidReply)?;
    let controllers = ControllerSet::new(
        value
            .settings
            .controllers
            .0
            .into_iter()
            .map(|principal| principal.to_text())
            .collect(),
    )?;
    Ok(IcCanisterStatusInfo {
        status: value.status,
        controllers,
    })
}