use crate::config::{Config, ConfigError, schema::ConfigModel};
use std::sync::Arc;
#[cfg(any(not(target_arch = "wasm32"), test))]
mod render;
#[doc(hidden)]
pub mod compiled {
pub use crate::{
cdk::{candid::Principal, types::Cycles},
config::schema::{
AppConfig, AppInitMode, AuthConfig, CanisterConfig, CanisterKind, CanisterPool,
ConfigModel, DelegatedAuthCanisterConfig, DelegatedTokenConfig,
DelegationProofCacheConfig, DelegationProofCacheProfile, DirectoryConfig,
DirectoryPool, LogConfig, PoolImport, RandomnessConfig, RandomnessSource,
RoleAttestationConfig, ScalePool, ScalePoolPolicy, ScalingConfig, ShardPool,
ShardPoolPolicy, ShardingConfig, Standards, StandardsCanisterConfig, SubnetConfig,
TopupPolicy, Whitelist,
},
ids::{CanisterRole, SubnetRole},
};
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct EmbeddedRootBootstrapEntry {
pub role: &'static str,
pub wasm_module: &'static [u8],
pub artifact_path: &'static str,
pub embedded_artifact_path: &'static str,
pub artifact_kind: &'static str,
pub artifact_size_bytes: u64,
pub artifact_sha256_hex: &'static str,
pub decompressed_size_bytes: Option<u64>,
pub decompressed_sha256_hex: Option<&'static str>,
}
pub fn init_compiled_config(
config: ConfigModel,
source_toml: &str,
) -> Result<Arc<ConfigModel>, ConfigError> {
Config::init_from_model(config, source_toml)
}
#[cfg(any(not(target_arch = "wasm32"), test))]
pub fn parse_config_model(toml: &str) -> Result<ConfigModel, ConfigError> {
Config::parse_toml(toml)
}
#[cfg(any(not(target_arch = "wasm32"), test))]
#[must_use]
pub fn compact_config_source(toml: &str) -> String {
let mut compact = String::new();
for line in toml.lines() {
let trimmed = line.trim();
if trimmed.is_empty() || trimmed.starts_with('#') {
continue;
}
compact.push_str(trimmed);
compact.push('\n');
}
compact
}
#[cfg(any(not(target_arch = "wasm32"), test))]
#[must_use]
pub fn emit_config_model_source(config: &ConfigModel) -> String {
render::config_model(config)
}