Crate canic_core

Crate canic_core 

Source
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! (in build.rs) to validate/embed canic.toml
  • canic::start! / canic::start_root! (in lib.rs) to wire lifecycle hooks and export endpoints

§Layering

Canic is organized to keep endpoint code thin and policies centralized:

  • access/ contains guard/auth/rule helpers for boundary enforcement.
  • workflow/ implements orchestration and lifecycle workflows.
  • policy/ owns deterministic decision rules.
  • ops/ provides mechanical, reusable side-effecting operations.
  • model/ owns storage (stable memory) and in-process registries/caches.
  • macros/ provides public macro entrypoints and endpoint bundles.

The default flow is: endpoints → workflow → policy → ops → model.

Re-exports§

pub use dto::error::Error as PublicError;
pub use dto::error::ErrorCode;
pub use ::canic_cdk as cdk;
pub use ::canic_memory as memory;
pub use ::canic_utils as utils;

Modules§

access
api
Public API façade for canister endpoints.
domain
dto
DTO boundary definitions.
ids
Shared type wrappers and aliases used across the ops and endpoint layers.
log
macros
Public macro entry points used across Canic.
perf
Cross-cutting performance instrumentation.
protocol

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 $body during process start-up using ctor.
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.
start
Configure lifecycle hooks for non-root Canic canisters.
start_root
Configure lifecycle hooks for the root orchestrator canister.
timer
timer Schedule a one-shot timer with an auto-generated label.
timer_guarded
timer_guarded Schedule a one-shot timer if none is already scheduled for the slot. Returns true when a new timer was scheduled.
timer_interval
timer_interval Schedule a repeating timer with an auto-generated label.
timer_interval_guarded
timer_interval_guarded Schedule an init timer that installs a repeating timer for the slot. Returns true when a new timer was scheduled.

Constants§

CRATE_NAME
Crate Version
VERSION

Functions§

init_config

Derive Macros§

ThisError