canic_core/
lib.rs

1//! Core Canic library used inside canisters.
2//!
3//! Most users should depend on the `canic` facade crate, which re-exports this crate
4//! under `canic::core` and exposes the common entrypoint macros:
5//! - `canic::build!` / `canic::build_root!` (in `build.rs`) to validate/embed `canic.toml`
6//! - `canic::start!` / `canic::start_root!` (in `lib.rs`) to wire lifecycle hooks and export endpoints
7//!
8//! ## Layering
9//!
10//! Canic is organized to keep endpoint code thin and policies centralized:
11//! - `access/` contains guard/auth/rule helpers for boundary enforcement.
12//! - `workflow/` implements orchestration and lifecycle workflows.
13//! - `policy/` owns deterministic decision rules.
14//! - `ops/` provides mechanical, reusable side-effecting operations.
15//! - `model/` owns storage (stable memory) and in-process registries/caches.
16//! - macro entrypoints live in the `canic` facade crate.
17//!
18//! The default flow is: endpoints → workflow → policy → ops → model.
19
20pub mod access;
21pub mod api;
22pub mod bootstrap;
23#[doc(hidden)]
24pub mod dispatch;
25pub mod domain;
26pub mod dto;
27pub mod error;
28pub mod ids;
29pub mod log;
30pub mod perf;
31pub mod protocol;
32#[cfg(test)]
33pub mod test;
34
35pub(crate) mod config;
36pub(crate) mod infra;
37pub(crate) mod lifecycle;
38pub(crate) mod ops;
39pub(crate) mod storage;
40pub(crate) mod workflow;
41
42pub use {
43    ::canic_cdk as cdk,
44    ::canic_memory as memory,
45    ::canic_memory::{eager_init, eager_static, ic_memory, ic_memory_range},
46    ::canic_utils as utils,
47};
48
49pub(crate) use error::{InternalError, InternalErrorClass, InternalErrorOrigin};
50
51/// Internal re-exports required for macro expansion.
52/// Not part of the public API.
53#[doc(hidden)]
54pub mod __reexports {
55    pub use ::ctor;
56}
57
58///
59/// Consts
60///
61
62pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
63pub const VERSION: &str = env!("CARGO_PKG_VERSION");