junobuild_cdn/
strategies.rs

1use crate::proposals::{Proposal, ProposalsStable};
2use crate::storage::{ProposalAssetsStable, ProposalContentChunksStable};
3use junobuild_collections::types::rules::Rules;
4use junobuild_shared::types::domain::CustomDomains;
5use junobuild_storage::types::config::StorageConfig;
6use junobuild_storage::types::state::AssetsHeap;
7
8pub trait CdnHeapStrategy {
9    fn with_assets<R>(&self, f: impl FnOnce(&AssetsHeap) -> R) -> R;
10    fn with_assets_mut<R>(&self, f: impl FnOnce(&mut AssetsHeap) -> R) -> R;
11
12    fn with_config<R>(&self, f: impl FnOnce(&StorageConfig) -> R) -> R;
13    fn with_config_mut<R>(&self, f: impl FnOnce(&mut StorageConfig) -> R) -> R;
14
15    fn with_rules<R>(&self, f: impl FnOnce(&Rules) -> R) -> R;
16
17    fn with_domains<R>(&self, f: impl FnOnce(&CustomDomains) -> R) -> R;
18    fn with_domains_mut<R>(&self, f: impl FnOnce(&mut CustomDomains) -> R) -> R;
19}
20
21pub trait CdnStableStrategy {
22    fn with_assets<R>(&self, f: impl FnOnce(&ProposalAssetsStable) -> R) -> R;
23    fn with_assets_mut<R>(&self, f: impl FnOnce(&mut ProposalAssetsStable) -> R) -> R;
24
25    fn with_content_chunks<R>(&self, f: impl FnOnce(&ProposalContentChunksStable) -> R) -> R;
26    fn with_content_chunks_mut<R>(
27        &self,
28        f: impl FnOnce(&mut ProposalContentChunksStable) -> R,
29    ) -> R;
30
31    fn with_proposals<R>(&self, f: impl FnOnce(&ProposalsStable) -> R) -> R;
32    fn with_proposals_mut<R>(&self, f: impl FnOnce(&mut ProposalsStable) -> R) -> R;
33}
34
35pub trait CdnWorkflowStrategy {
36    fn pre_commit_assets(&self, proposal: &Proposal);
37    fn post_commit_assets(&self, proposal: &Proposal) -> Result<(), String>;
38}