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!` / `build_root!` for strict configured canisters
7//! - `build_standalone!` for sandbox/probe canisters with generated minimal config
8//! - `start!` / `start_root!` for `lib.rs` (wire lifecycle hooks and export endpoints)
9//!
10//! For lower-level access, use the `api`, `cdk`, and `memory` modules.
11//! Direct access to internal core modules is intentionally unsupported.
12
13pub mod access;
14pub mod api;
15#[cfg(any(not(target_arch = "wasm32"), test))]
16mod build_support;
17pub mod dto;
18pub mod ids;
19mod instructions;
20mod macros; // private implementation boundary
21pub mod prelude;
22pub mod protocol;
23
24#[doc(hidden)]
25pub mod __internal {
26 // NOTE:
27 // This module exists ONLY for macro expansion.
28 // Do NOT re-export canic_core publicly.
29 #[cfg(feature = "control-plane")]
30 pub use canic_control_plane as control_plane;
31 pub use canic_core as core;
32
33 pub mod instructions {
34 pub use crate::instructions::format_instructions;
35 }
36}
37
38#[doc(hidden)]
39#[cfg(any(not(target_arch = "wasm32"), test))]
40pub mod __build {
41 pub use crate::build_support::{
42 METRICS_TIER_CORE, METRICS_TIER_PLACEMENT, METRICS_TIER_PLATFORM, METRICS_TIER_RUNTIME,
43 METRICS_TIER_SECURITY, METRICS_TIER_STORAGE, emit_root_wasm_store_bootstrap_release_set,
44 metrics_profile_tier_mask, read_config_source_or_default,
45 };
46}
47
48// -----------------------------------------------------------------------------
49// Sub-crates
50// -----------------------------------------------------------------------------
51pub use canic_cdk as cdk;
52pub use canic_memory as memory;
53
54// -----------------------------------------------------------------------------
55// Re-exports
56// -----------------------------------------------------------------------------
57pub use canic_core::dto::error::Error;
58pub use canic_macros::{canic_query, canic_update};
59
60// -----------------------------------------------------------------------------
61// Constants
62// -----------------------------------------------------------------------------
63
64pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
65pub const VERSION: &str = env!("CARGO_PKG_VERSION");
66pub const CANIC_WASM_CHUNK_BYTES: usize = canic_core::CANIC_WASM_CHUNK_BYTES;
67pub const CANIC_DEFAULT_UPDATE_INGRESS_MAX_BYTES: usize =
68 canic_core::ingress::payload::DEFAULT_UPDATE_INGRESS_MAX_BYTES;