canic_core/bootstrap.rs
1use crate::config::{Config, schema::ConfigModel};
2use std::sync::Arc;
3
4/// Parse, validate, and install the Canic configuration.
5///
6/// This function is intentionally:
7/// - deterministic
8/// - synchronous
9/// - side-effect limited to internal config state
10///
11/// It is safe to call from both build-time validation and
12/// canister init / post-upgrade bootstrap paths.
13pub fn init_config(toml: &str) -> Result<(), String> {
14 parse_and_install_config(toml).map(|_| ())
15}
16
17fn parse_and_install_config(toml: &str) -> Result<Arc<ConfigModel>, String> {
18 Config::init_from_toml(toml).map_err(|err| err.to_string())
19}