Skip to main content

canic_host/frontend/view/
mod.rs

1//! Read-only projections used while assembling a frontend handoff.
2
3use crate::{frontend::model::FrontendManifestRecord, registry::RegistryEntry};
4use canic_core::ids::CanonicalNetworkId;
5use std::collections::BTreeMap;
6
7///
8/// FrontendAssetChunkView
9///
10/// First asset query response, before comparison with the exact handoff identity.
11///
12
13pub struct FrontendAssetChunkView {
14    pub content: Vec<u8>,
15    pub total_length: u64,
16    pub encoding: String,
17    pub sha256: Option<Vec<u8>>,
18}
19
20///
21/// FrontendUploadedFileView
22///
23/// Expected remote identity of one verified handoff file.
24///
25
26#[derive(Debug, Eq, PartialEq, serde::Serialize)]
27pub struct FrontendUploadedFileView {
28    pub key: String,
29    pub bytes: u64,
30    pub sha256: String,
31}
32
33///
34/// FrontendUploadView
35///
36/// Exact files observed during one read-only asset verification.
37///
38
39#[derive(Debug, Eq, PartialEq, serde::Serialize)]
40pub struct FrontendUploadView {
41    pub environment: String,
42    pub canister_id: candid::Principal,
43    pub manifest_sha256: String,
44    pub files: Vec<FrontendUploadedFileView>,
45}
46
47/// Bounded byte inventory of exactly the static assets selected for upload.
48#[derive(Debug, Eq, PartialEq, serde::Serialize)]
49pub struct FrontendPayloadView {
50    pub files: u32,
51    pub bytes: u64,
52    pub sha256: String,
53}
54
55/// External native-balance observation compared with an explicit operator floor.
56#[derive(Debug, Eq, PartialEq, serde::Serialize)]
57pub struct FrontendAssetCapacityView {
58    pub environment: String,
59    pub canister_id: String,
60    pub observed_at_unix_secs: u64,
61    pub native_cycles: String,
62    pub minimum_native_cycles: String,
63    pub payload: FrontendPayloadView,
64    pub sufficient: bool,
65}
66
67/// Selected terminal authority without protected Registry or admission records.
68pub struct FrontendAuthorityView {
69    pub app: String,
70    pub fleet: String,
71    pub fleet_id: String,
72    pub source_plan_sha256: String,
73    pub network: CanonicalNetworkId,
74    pub admission_nonempty: bool,
75    pub admission_origin: Option<String>,
76    pub entries: Vec<RegistryEntry>,
77}
78
79/// Completely prepared immutable browser bundle; manifest publication happens last.
80pub struct FrontendBundleView {
81    pub manifest: FrontendManifestRecord,
82    pub files: BTreeMap<String, Vec<u8>>,
83}
84
85/// Generated browser and TypeScript modules for one checked Candid service.
86pub struct FrontendBindingsView {
87    pub javascript: Vec<u8>,
88    pub typescript: Vec<u8>,
89}