#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_nonroot_lifecycle_core {
($canister_role:expr $(, $init:block)?) => {
#[doc(hidden)]
fn __canic_compiled_config() -> (
$crate::__internal::core::bootstrap::compiled::ConfigModel,
&'static str,
&'static str,
) {
let config_model = include!(env!("CANIC_CONFIG_MODEL_PATH"));
let config_source = include_str!(env!("CANIC_CONFIG_SOURCE_PATH"));
let config_path = env!("CANIC_CONFIG_PATH");
(config_model, config_source, config_path)
}
#[::canic::cdk::init]
fn init(payload: ::canic::dto::abi::v1::CanisterInitPayload, args: Option<Vec<u8>>) {
let (config, config_source, config_path) = __canic_compiled_config();
#[cfg(any(
canic_accepts_delegation_signer_proof,
canic_accepts_delegation_verifier_proof
))]
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::init_nonroot_canister_before_bootstrap_with_attestation_cache(
$canister_role,
payload,
config,
config_source,
config_path,
);
#[cfg(not(any(
canic_accepts_delegation_signer_proof,
canic_accepts_delegation_verifier_proof
)))]
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::init_nonroot_canister_before_bootstrap(
$canister_role,
payload,
config,
config_source,
config_path,
);
$crate::__canic_run_start_init_hook!($($init)?);
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::schedule_init_nonroot_bootstrap(args.clone());
$crate::__canic_start_nonroot_user_timers!(args);
}
#[::canic::cdk::post_upgrade]
fn post_upgrade() {
let (config, config_source, config_path) = __canic_compiled_config();
#[cfg(any(
canic_accepts_delegation_signer_proof,
canic_accepts_delegation_verifier_proof
))]
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::post_upgrade_nonroot_canister_before_bootstrap_with_attestation_cache(
$canister_role,
config,
config_source,
config_path,
);
#[cfg(not(any(
canic_accepts_delegation_signer_proof,
canic_accepts_delegation_verifier_proof
)))]
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::post_upgrade_nonroot_canister_before_bootstrap(
$canister_role,
config,
config_source,
config_path,
);
$crate::__canic_run_start_init_hook!($($init)?);
$crate::__internal::core::api::lifecycle::nonroot::LifecycleApi::schedule_post_upgrade_nonroot_bootstrap();
$crate::__canic_start_nonroot_upgrade_timers!();
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_root_lifecycle_core {
($( $init:block )?) => {
#[doc(hidden)]
fn __canic_compiled_config() -> (
$crate::__internal::core::bootstrap::compiled::ConfigModel,
&'static str,
&'static str,
) {
let config_model = include!(env!("CANIC_CONFIG_MODEL_PATH"));
let config_source = include_str!(env!("CANIC_CONFIG_SOURCE_PATH"));
let config_path = env!("CANIC_CONFIG_PATH");
(config_model, config_source, config_path)
}
#[doc(hidden)]
#[cfg(canic_has_root_release_bundle)]
fn __canic_embedded_root_release_bundle(
) -> &'static [$crate::__internal::core::bootstrap::EmbeddedRootReleaseEntry] {
include!(env!("CANIC_ROOT_RELEASE_BUNDLE_PATH"))
}
#[doc(hidden)]
#[cfg(not(canic_has_root_release_bundle))]
fn __canic_embedded_root_release_bundle(
) -> &'static [$crate::__internal::core::bootstrap::EmbeddedRootReleaseEntry] {
&[]
}
#[doc(hidden)]
#[cfg(canic_has_root_wasm_store_bootstrap_release_set)]
fn __canic_embedded_root_wasm_store_bootstrap_release_set(
) -> &'static [$crate::__internal::core::bootstrap::EmbeddedRootBootstrapEntry] {
include!(env!("CANIC_ROOT_WASM_STORE_BOOTSTRAP_RELEASE_SET_PATH"))
}
#[doc(hidden)]
#[cfg(not(canic_has_root_wasm_store_bootstrap_release_set))]
fn __canic_embedded_root_wasm_store_bootstrap_release_set(
) -> &'static [$crate::__internal::core::bootstrap::EmbeddedRootBootstrapEntry] {
&[]
}
#[::canic::cdk::init]
fn init(identity: ::canic::dto::subnet::SubnetIdentity) {
let (config, config_source, config_path) = __canic_compiled_config();
let embedded_wasm_store_bootstrap_release_set =
__canic_embedded_root_wasm_store_bootstrap_release_set();
let embedded_release_bundle = __canic_embedded_root_release_bundle();
let embedded_release_version = env!("CARGO_PKG_VERSION");
$crate::__internal::control_plane::api::lifecycle::LifecycleApi::init_root_canister_before_bootstrap(
identity,
config,
config_source,
config_path,
embedded_wasm_store_bootstrap_release_set,
embedded_release_bundle,
embedded_release_version,
);
$crate::__canic_run_start_init_hook!($($init)?);
$crate::__internal::control_plane::api::lifecycle::LifecycleApi::schedule_init_root_bootstrap();
$crate::__canic_start_root_user_timers!();
}
#[::canic::cdk::post_upgrade]
fn post_upgrade() {
let (config, config_source, config_path) = __canic_compiled_config();
let embedded_wasm_store_bootstrap_release_set =
__canic_embedded_root_wasm_store_bootstrap_release_set();
let embedded_release_bundle = __canic_embedded_root_release_bundle();
let embedded_release_version = env!("CARGO_PKG_VERSION");
$crate::__internal::control_plane::api::lifecycle::LifecycleApi::post_upgrade_root_canister_before_bootstrap(
config,
config_source,
config_path,
embedded_wasm_store_bootstrap_release_set,
embedded_release_bundle,
embedded_release_version,
);
$crate::__canic_run_start_init_hook!($($init)?);
$crate::__internal::control_plane::api::lifecycle::LifecycleApi::schedule_post_upgrade_root_bootstrap();
$crate::__canic_start_root_upgrade_timers!();
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_run_start_init_hook {
() => {};
($init:block) => {{ $init }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_nonroot_user_timers {
($args:expr) => {
$crate::__internal::core::api::timer::TimerApi::set_lifecycle_timer(
::std::time::Duration::ZERO,
"canic:user:init",
async move {
canic_setup().await;
canic_install($args).await;
},
);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_nonroot_upgrade_timers {
() => {
$crate::__internal::core::api::timer::TimerApi::set_lifecycle_timer(
::core::time::Duration::ZERO,
"canic:user:init",
async move {
canic_setup().await;
canic_upgrade().await;
},
);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_root_user_timers {
() => {
$crate::__internal::core::api::timer::TimerApi::set_lifecycle_timer(
::core::time::Duration::ZERO,
"canic:user:init",
async move {
canic_setup().await;
canic_install().await;
},
);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_root_upgrade_timers {
() => {
$crate::__internal::core::api::timer::TimerApi::set_lifecycle_timer(
::core::time::Duration::ZERO,
"canic:user:init",
async move {
canic_setup().await;
canic_upgrade().await;
},
);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_nonroot_capability_bundles {
() => {
$crate::canic_bundle_shared_runtime_endpoints!();
$crate::canic_bundle_nonroot_only_endpoints!();
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_start_root_capability_bundles {
() => {
$crate::canic_bundle_shared_runtime_endpoints!();
$crate::canic_bundle_root_only_endpoints!();
};
}
#[macro_export]
macro_rules! start {
($canister_role:expr $(, init = $init:block)? $(,)?) => {
$crate::__canic_start_nonroot_lifecycle_core!($canister_role $(, $init)?);
$crate::__canic_start_nonroot_capability_bundles!();
};
}
#[macro_export]
macro_rules! start_root {
($(init = $init:block)? $(,)?) => {
$crate::__canic_start_root_lifecycle_core!($($init)?);
$crate::__canic_start_root_capability_bundles!();
};
}
#[macro_export]
macro_rules! start_wasm_store {
($(init = $init:block)? $(,)?) => {
#[allow(clippy::unused_async)]
async fn canic_setup() {}
#[allow(clippy::unused_async)]
async fn canic_install(_: Option<Vec<u8>>) {}
#[allow(clippy::unused_async)]
async fn canic_upgrade() {}
$crate::start!($crate::api::canister::CanisterRole::WASM_STORE $(, init = $init)?);
$crate::canic_emit_local_wasm_store_endpoints!();
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __canic_load_config {
() => {{
let config_path = env!("CANIC_CONFIG_PATH");
let config_str = include_str!(env!("CANIC_CONFIG_SOURCE_PATH"));
(config_str, config_path)
}};
}