1pub use candid;
8pub use ic_cdk::{
9 api, call, eprintln, export_candid, futures, init, inspect_message, post_upgrade, println,
10 query, trap, update,
11};
12pub use ic_cdk_management_canister as mgmt;
13pub use ic_cdk_timers as timers;
14pub use icrc_ledger_types;
15
16pub mod serialize;
17pub mod spec;
18pub mod structures;
19pub mod types;
20pub mod utils;
21
22#[macro_export]
29macro_rules! impl_storable_bounded {
30 ($ident:ident, $max_size:expr, $is_fixed_size:expr) => {
31 impl $crate::cdk::structures::storable::Storable for $ident {
32 const BOUND: $crate::cdk::structures::storable::Bound =
33 $crate::cdk::structures::storable::Bound::Bounded {
34 max_size: $max_size,
35 is_fixed_size: $is_fixed_size,
36 };
37
38 fn to_bytes(&self) -> ::std::borrow::Cow<'_, [u8]> {
39 let bytes = $crate::cdk::serialize::serialize(self).unwrap_or_else(|err| {
40 panic!("impl_storable_bounded: serialize failed: {err}");
41 });
42
43 ::std::borrow::Cow::Owned(bytes)
44 }
45
46 fn into_bytes(self) -> Vec<u8> {
47 $crate::cdk::serialize::serialize(&self).unwrap_or_else(|err| {
48 panic!("impl_storable_bounded: serialize failed: {err}");
49 })
50 }
51
52 fn from_bytes(bytes: ::std::borrow::Cow<'_, [u8]>) -> Self {
53 $crate::cdk::serialize::deserialize(&bytes).unwrap_or_else(|err| {
54 panic!("impl_storable_bounded: deserialize failed: {err}");
55 })
56 }
57 }
58 };
59}
60
61#[macro_export]
68macro_rules! impl_storable_unbounded {
69 ($ident:ident) => {
70 impl $crate::cdk::structures::storable::Storable for $ident {
71 const BOUND: $crate::cdk::structures::storable::Bound =
72 $crate::cdk::structures::storable::Bound::Unbounded;
73
74 fn to_bytes(&self) -> ::std::borrow::Cow<'_, [u8]> {
75 let bytes = $crate::cdk::serialize::serialize(self).unwrap_or_else(|err| {
76 panic!("impl_storable_unbounded: serialize failed: {err}");
77 });
78
79 ::std::borrow::Cow::Owned(bytes)
80 }
81
82 fn into_bytes(self) -> Vec<u8> {
83 $crate::cdk::serialize::serialize(&self).unwrap_or_else(|err| {
84 panic!("impl_storable_unbounded: serialize failed: {err}");
85 })
86 }
87
88 fn from_bytes(bytes: ::std::borrow::Cow<'_, [u8]>) -> Self {
89 $crate::cdk::serialize::deserialize(&bytes).unwrap_or_else(|err| {
90 panic!("impl_storable_unbounded: deserialize failed: {err}");
91 })
92 }
93 }
94 };
95}