Expand description
Core Canic library used inside canisters.
Most users should depend on the canic facade crate, which re-exports this crate
under canic::core and exposes the common entrypoint macros:
canic::build!/canic::build_root!(inbuild.rs) to validate/embedcanic.tomlcanic::start!/canic::start_root!(inlib.rs) to wire lifecycle hooks and export endpoints
§Layering
Canic is organized to keep endpoint code thin and policies centralized:
access/contains guard/auth/policy helpers for boundary enforcement.model/owns storage (stable memory) and in-process registries/caches.ops/implements workflows (provisioning, scaling, sharding, reserve management).macros/provides public macro entrypoints and endpoint bundles.
The default flow is: endpoints → ops → model.
Re-exports§
pub use access::auth;pub use access::guard;pub use access::policy;pub use ::canic_cdk as cdk;pub use ::canic_memory as memory;pub use ::canic_types as types;pub use ::canic_utils as utils;
Modules§
- access
- config
- dispatch
- dto
- env
- Environment constants grouped by domain (ck, NNS, SNS).
- ids
- Shared type wrappers and aliases used across the ops and endpoint layers.
- log
- macros
- Public macro entry points used across Canic.
- ops
- Business-logic helpers that sit between endpoint handlers and the state layer.
- perf
- Cross-cutting performance instrumentation.
- spec
- Canonical representations of external IC specs (ICRC, NNS, SNS, etc.). This module corrals the verbose candid bindings so the rest of the codebase can import clean wrappers with consistent naming.
Macros§
- auth_
require_ all - Enforce that every supplied rule future succeeds for the current caller.
- auth_
require_ any - Enforce that at least one supplied rule future succeeds for the current caller.
- build
- Embed the shared Canic configuration into a canister crate’s build script.
- build_
root - Embed the shared configuration for the root orchestrator canister.
- canic_
endpoints - canic_
endpoints_ nonroot - canic_
endpoints_ root - eager_
init - Run
$bodyduring process start-up usingctor. - eager_
static - Declare a thread-local static and schedule an eager initialization touch.
- ic_
memory - Declare a stable-memory slot backed by the Canic memory registry.
- ic_
memory_ range - Reserve a contiguous block of stable-memory IDs for the current crate.
- log
- perf
- Log elapsed instruction counts since the last
perf!invocation in this thread. - perf_
scope - start
- Configure lifecycle hooks for non-root Canic canisters.
- start_
root - Configure lifecycle hooks for the root Canic orchestrator canister.
- timer
- timer Schedule a one-shot timer with an auto-generated label.
- timer_
interval - timer_interval Schedule a repeating timer with an auto-generate label.
Enums§
- Error
- Error
Constants§
- CRATE_
NAME - Crate Version
- VERSION