canic_core/api/
mod.rs

1//! Public API façade for canister endpoints.
2//!
3//! This module contains thin wrappers exposed to proc-macro–generated
4//! endpoints. Functions here translate public API calls into internal
5//! workflow or ops calls and map internal errors into `PublicError`.
6//!
7//! No orchestration or business logic should live here.
8//! Any wrapper callable from an endpoint must return a `Result` so errors
9//! are consistently mapped at the boundary.
10
11pub mod access;
12pub mod bootstrap;
13pub mod cascade;
14pub mod config;
15pub mod error;
16pub mod ic;
17pub mod icts;
18pub mod lifecycle;
19pub mod placement;
20pub mod pool;
21pub mod rpc;
22pub mod state;
23pub mod timer;
24pub mod topology;
25pub mod wasm;
26
27///
28/// Query Wrappers
29/// (these modules have nothing else other than safe, public Query APIs)
30///
31
32pub mod cycles {
33    pub use crate::workflow::runtime::cycles::query::CycleTrackerQuery;
34}
35pub mod env {
36    pub use crate::workflow::env::query::EnvQuery;
37}
38pub mod icrc {
39    pub use crate::workflow::icrc::query::{Icrc10Query, Icrc21Query};
40}
41pub mod log {
42    pub use crate::workflow::log::query::LogQuery;
43}
44pub mod memory {
45    pub use crate::workflow::memory::query::MemoryQuery;
46}
47pub mod metrics {
48    pub use crate::workflow::metrics::query::MetricsQuery;
49}
50
51///
52/// Prelude
53///
54
55pub mod prelude {
56    pub use crate::{
57        PublicError,
58        cdk::types::{Account, Principal},
59    };
60}
61
62///
63/// EndpointCall
64///
65
66#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
67pub struct EndpointCall {
68    pub endpoint: EndpointId,
69    pub kind: EndpointCallKind,
70}
71
72///
73/// EndpointId
74///
75
76#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
77pub struct EndpointId {
78    pub name: &'static str,
79}
80
81impl EndpointId {
82    #[must_use]
83    pub const fn new(name: &'static str) -> Self {
84        Self { name }
85    }
86}
87
88///
89/// EndpointCallKind
90///
91
92#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
93pub enum EndpointCallKind {
94    Query,
95    QueryComposite,
96    Update,
97}