use crate::cdk::types::Principal;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ApprovedModuleSource {
source_canister: Principal,
source_label: String,
module_hash: Vec<u8>,
chunk_hashes: Vec<Vec<u8>>,
payload_size_bytes: u64,
}
impl ApprovedModuleSource {
#[must_use]
pub const fn chunked(
source_canister: Principal,
source_label: String,
module_hash: Vec<u8>,
chunk_hashes: Vec<Vec<u8>>,
payload_size_bytes: u64,
) -> Self {
Self {
source_canister,
source_label,
module_hash,
chunk_hashes,
payload_size_bytes,
}
}
#[must_use]
pub const fn source_canister(&self) -> &Principal {
&self.source_canister
}
#[must_use]
pub fn source_label(&self) -> &str {
&self.source_label
}
#[must_use]
pub fn module_hash(&self) -> &[u8] {
&self.module_hash
}
#[must_use]
pub const fn payload_size_bytes(&self) -> u64 {
self.payload_size_bytes
}
#[must_use]
pub fn chunk_hashes(&self) -> &[Vec<u8>] {
&self.chunk_hashes
}
#[must_use]
pub const fn chunk_count(&self) -> usize {
self.chunk_hashes.len()
}
}