canic_core/ops/runtime/
install_source.rs1use crate::cdk::types::Principal;
8
9#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct ApprovedModuleSource {
17 source_canister: Principal,
18 source_label: String,
19 module_hash: Vec<u8>,
20 chunk_hashes: Vec<Vec<u8>>,
21 payload_size_bytes: u64,
22}
23
24impl ApprovedModuleSource {
25 #[must_use]
27 pub const fn chunked(
28 source_canister: Principal,
29 source_label: String,
30 module_hash: Vec<u8>,
31 chunk_hashes: Vec<Vec<u8>>,
32 payload_size_bytes: u64,
33 ) -> Self {
34 Self {
35 source_canister,
36 source_label,
37 module_hash,
38 chunk_hashes,
39 payload_size_bytes,
40 }
41 }
42
43 #[must_use]
45 pub const fn source_canister(&self) -> &Principal {
46 &self.source_canister
47 }
48
49 #[must_use]
51 pub fn source_label(&self) -> &str {
52 &self.source_label
53 }
54
55 #[must_use]
57 pub fn module_hash(&self) -> &[u8] {
58 &self.module_hash
59 }
60
61 #[must_use]
63 pub const fn payload_size_bytes(&self) -> u64 {
64 self.payload_size_bytes
65 }
66
67 #[must_use]
69 pub fn chunk_hashes(&self) -> &[Vec<u8>] {
70 &self.chunk_hashes
71 }
72
73 #[must_use]
75 pub const fn chunk_count(&self) -> usize {
76 self.chunk_hashes.len()
77 }
78}