ic-backup 0.64.1

Host-side snapshot backup and same-release recovery for Internet Computer canisters
Documentation
//! Bounded data vector decoding; no skipped extensions or untrusted allocation.
use super::{
    IcSnapshotDataError, MAX_IC_SNAPSHOT_DATA_CHUNK_BYTES, MAX_IC_SNAPSHOT_DATA_REPLY_BYTES,
};
use crate::model::ic_candid::BoundedVec;
use ic_platform::candid_codec::decoder::{Limits, decode_one_with_skip_limit};
struct WireData {
    chunk: BoundedVec<u8, MAX_IC_SNAPSHOT_DATA_CHUNK_BYTES>,
}
ic_platform::candid_record!(WireData {
    1_170_392_685 => chunk: BoundedVec<u8, MAX_IC_SNAPSHOT_DATA_CHUNK_BYTES>,
});

pub(super) fn decode(bytes: &[u8]) -> Result<Vec<u8>, IcSnapshotDataError> {
    let value: WireData = decode_one_with_skip_limit(
        bytes,
        Limits {
            bytes: MAX_IC_SNAPSHOT_DATA_REPLY_BYTES,
            header: 4096,
            types: 16,
            work: 8 * 1024 * 1024,
            allocation: 2 * 1024 * 1024,
        },
        0,
    )
    .map_err(|_| IcSnapshotDataError::InvalidReply)?;
    Ok(value.chunk.0)
}