Skip to main content

canic_core/api/lifecycle/
nonroot.rs

1use crate::{
2    config::RoleRuntimeAuthority,
3    dto::{
4        abi::v1::CanisterInitPayload, env::EnvBootstrapArgs,
5        fleet_subnet_root::FleetSubnetWasmStoreInitArgs,
6    },
7    ids::{CanisterRole, ManagedCanisterBinding},
8    lifecycle,
9};
10
11///
12/// LifecycleApi
13///
14
15pub struct LifecycleApi;
16
17impl LifecycleApi {
18    #[doc(hidden)]
19    pub fn configure_component_runtime_with_automatic_topup(
20        request: crate::dto::component_registry::ComponentRuntimeDirectoryPreparationRequest,
21    ) -> Result<
22        crate::view::fleet_activation::ComponentRuntimeActivationTransition,
23        crate::dto::error::Error,
24    > {
25        crate::workflow::component_runtime::configure_with_automatic_topup(request)
26            .map_err(Into::into)
27    }
28
29    /// Return the immutable Registry-issued identity retained by this application Canister.
30    pub fn managed_binding() -> Result<ManagedCanisterBinding, crate::dto::error::Error> {
31        crate::ops::runtime::env::EnvOps::managed_binding().map_err(Into::into)
32    }
33
34    pub fn init_nonroot_canister_before_bootstrap(
35        role: CanisterRole,
36        payload: CanisterInitPayload,
37        application_init_args: Option<Vec<u8>>,
38        embedded_release_build_id: Option<&str>,
39        authority: RoleRuntimeAuthority,
40    ) {
41        lifecycle::init::nonroot::init_nonroot_canister_before_bootstrap(
42            role,
43            payload,
44            application_init_args,
45            embedded_release_build_id,
46            authority,
47        );
48    }
49
50    pub fn init_wasm_store_before_bootstrap(
51        input: FleetSubnetWasmStoreInitArgs,
52        embedded_release_build_id: Option<&str>,
53        authority: RoleRuntimeAuthority,
54    ) {
55        lifecycle::init::nonroot::init_wasm_store_before_bootstrap(
56            input,
57            embedded_release_build_id,
58            authority,
59        );
60    }
61
62    pub fn schedule_init_nonroot_bootstrap() {
63        lifecycle::init::nonroot::schedule_init_nonroot_bootstrap();
64    }
65
66    pub fn init_local_nonroot_canister_before_bootstrap(
67        role: CanisterRole,
68        env: EnvBootstrapArgs,
69        authority: RoleRuntimeAuthority,
70    ) {
71        lifecycle::init::nonroot::init_local_nonroot_canister_before_bootstrap(
72            role, env, authority,
73        );
74    }
75
76    #[doc(hidden)]
77    pub fn init_local_nonroot_canister_with_automatic_topup_before_bootstrap(
78        role: CanisterRole,
79        env: EnvBootstrapArgs,
80        authority: RoleRuntimeAuthority,
81    ) {
82        lifecycle::init::nonroot::init_local_nonroot_canister_with_automatic_topup_before_bootstrap(
83            role, env, authority,
84        );
85    }
86
87    #[must_use]
88    pub fn post_upgrade_nonroot_canister_before_bootstrap(
89        role: CanisterRole,
90        embedded_release_build_id: Option<&str>,
91        authority: RoleRuntimeAuthority,
92    ) -> bool {
93        lifecycle::upgrade::nonroot::post_upgrade_nonroot_canister_before_bootstrap(
94            role,
95            embedded_release_build_id,
96            authority,
97        )
98    }
99
100    #[doc(hidden)]
101    #[must_use]
102    pub fn post_upgrade_nonroot_canister_with_automatic_topup_before_bootstrap(
103        role: CanisterRole,
104        embedded_release_build_id: Option<&str>,
105        authority: RoleRuntimeAuthority,
106    ) -> bool {
107        lifecycle::upgrade::nonroot::post_upgrade_nonroot_canister_with_automatic_topup_before_bootstrap(
108            role,
109            embedded_release_build_id,
110            authority,
111        )
112    }
113
114    pub fn schedule_post_upgrade_nonroot_bootstrap() {
115        lifecycle::upgrade::nonroot::schedule_post_upgrade_nonroot_bootstrap();
116    }
117
118    #[must_use]
119    pub fn post_upgrade_local_nonroot_canister_before_bootstrap(
120        role: CanisterRole,
121        authority: RoleRuntimeAuthority,
122    ) -> bool {
123        lifecycle::upgrade::nonroot::post_upgrade_local_nonroot_canister_before_bootstrap(
124            role, authority,
125        )
126    }
127
128    #[doc(hidden)]
129    #[must_use]
130    pub fn post_upgrade_local_nonroot_canister_with_automatic_topup_before_bootstrap(
131        role: CanisterRole,
132        authority: RoleRuntimeAuthority,
133    ) -> bool {
134        lifecycle::upgrade::nonroot::post_upgrade_local_nonroot_canister_with_automatic_topup_before_bootstrap(
135            role,
136            authority,
137        )
138    }
139}