Skip to main content

canic/
lib.rs

1//! Canic facade crate.
2//!
3//! This crate is the recommended dependency for downstream canister projects. It
4//! re-exports the public Canic runtime surface and provides the common macro entry points:
5//!
6//! - `build!` for configured canisters and generated local sandbox/probe config
7//! - `start!` for `lib.rs` (wire lifecycle hooks and export endpoints)
8//!
9//! For lower-level access, use the `api`, `cdk`, and `memory` modules.
10//! Direct access to internal core modules is intentionally unsupported.
11
12pub mod access;
13pub mod api;
14#[cfg(any(not(target_arch = "wasm32"), test))]
15mod build_support;
16pub mod dto;
17pub mod ids;
18mod instructions;
19mod macros; // private implementation boundary
20pub mod prelude;
21pub mod protocol;
22
23#[doc(hidden)]
24pub mod __internal {
25    // NOTE:
26    // This module exists ONLY for macro expansion.
27    // Do NOT re-export canic_core publicly.
28    #[cfg(feature = "control-plane")]
29    pub use canic_control_plane as control_plane;
30    pub use canic_core as core;
31
32    pub mod instructions {
33        pub use crate::instructions::format_instructions;
34    }
35}
36
37#[doc(hidden)]
38#[cfg(any(not(target_arch = "wasm32"), test))]
39pub mod __build {
40    pub use crate::build_support::{
41        METRICS_TIER_CORE, METRICS_TIER_PLACEMENT, METRICS_TIER_PLATFORM, METRICS_TIER_RUNTIME,
42        METRICS_TIER_SECURITY, METRICS_TIER_STORAGE, config_attaches_role, config_contains_role,
43        config_declares_role, config_fleet_name, declared_package_metadata, declared_package_role,
44        emit_root_wasm_store_bootstrap_release_set, metrics_profile_tier_mask,
45        read_config_source_or_default, required_package_metadata, required_package_role,
46    };
47}
48
49// -----------------------------------------------------------------------------
50// Sub-crates
51// -----------------------------------------------------------------------------
52pub use canic_core::cdk;
53pub use canic_core::memory;
54
55// -----------------------------------------------------------------------------
56// Re-exports
57// -----------------------------------------------------------------------------
58pub use canic_core::dto::error::Error;
59pub use canic_core::{impl_storable_bounded, impl_storable_unbounded};
60pub use canic_macros::{canic_query, canic_update};
61
62// -----------------------------------------------------------------------------
63// Constants
64// -----------------------------------------------------------------------------
65
66pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
67pub const VERSION: &str = env!("CARGO_PKG_VERSION");
68pub const CANIC_WASM_CHUNK_BYTES: usize = canic_core::CANIC_WASM_CHUNK_BYTES;
69pub const CANIC_DEFAULT_UPDATE_INGRESS_MAX_BYTES: usize =
70    canic_core::ingress::payload::DEFAULT_UPDATE_INGRESS_MAX_BYTES;