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!` / `build_root!` for `build.rs` (validate/embed `canic.toml`)
7//! - `start!` / `start_root!` 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::emit_root_wasm_store_bootstrap_release_set;
41}
42
43// -----------------------------------------------------------------------------
44// Sub-crates
45// -----------------------------------------------------------------------------
46pub use canic_cdk as cdk;
47pub use canic_memory as memory;
48
49// -----------------------------------------------------------------------------
50// Re-exports
51// -----------------------------------------------------------------------------
52pub use canic_core::dto::error::Error;
53pub use canic_dsl_macros::{canic_query, canic_update};
54
55// -----------------------------------------------------------------------------
56// Constants
57// -----------------------------------------------------------------------------
58
59pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
60pub const VERSION: &str = env!("CARGO_PKG_VERSION");
61pub const CANIC_WASM_CHUNK_BYTES: usize = canic_core::CANIC_WASM_CHUNK_BYTES;