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_timers as timers;
13
14pub mod serialize;
15pub mod spec;
16pub mod structures;
17pub mod types;
18pub mod utils;
19
20#[macro_export]
27macro_rules! impl_storable_bounded {
28 ($ident:ident, $max_size:expr, $is_fixed_size:expr) => {
29 impl $crate::cdk::structures::storable::Storable for $ident {
30 const BOUND: $crate::cdk::structures::storable::Bound =
31 $crate::cdk::structures::storable::Bound::Bounded {
32 max_size: $max_size,
33 is_fixed_size: $is_fixed_size,
34 };
35
36 fn to_bytes(&self) -> ::std::borrow::Cow<'_, [u8]> {
37 let bytes = $crate::cdk::serialize::serialize(self).unwrap_or_else(|err| {
38 panic!("impl_storable_bounded: serialize failed: {err}");
39 });
40
41 ::std::borrow::Cow::Owned(bytes)
42 }
43
44 fn into_bytes(self) -> Vec<u8> {
45 $crate::cdk::serialize::serialize(&self).unwrap_or_else(|err| {
46 panic!("impl_storable_bounded: serialize failed: {err}");
47 })
48 }
49
50 fn from_bytes(bytes: ::std::borrow::Cow<'_, [u8]>) -> Self {
51 $crate::cdk::serialize::deserialize(&bytes).unwrap_or_else(|err| {
52 panic!("impl_storable_bounded: deserialize failed: {err}");
53 })
54 }
55 }
56 };
57}
58
59#[macro_export]
66macro_rules! impl_storable_unbounded {
67 ($ident:ident) => {
68 impl $crate::cdk::structures::storable::Storable for $ident {
69 const BOUND: $crate::cdk::structures::storable::Bound =
70 $crate::cdk::structures::storable::Bound::Unbounded;
71
72 fn to_bytes(&self) -> ::std::borrow::Cow<'_, [u8]> {
73 let bytes = $crate::cdk::serialize::serialize(self).unwrap_or_else(|err| {
74 panic!("impl_storable_unbounded: serialize failed: {err}");
75 });
76
77 ::std::borrow::Cow::Owned(bytes)
78 }
79
80 fn into_bytes(self) -> Vec<u8> {
81 $crate::cdk::serialize::serialize(&self).unwrap_or_else(|err| {
82 panic!("impl_storable_unbounded: serialize failed: {err}");
83 })
84 }
85
86 fn from_bytes(bytes: ::std::borrow::Cow<'_, [u8]>) -> Self {
87 $crate::cdk::serialize::deserialize(&bytes).unwrap_or_else(|err| {
88 panic!("impl_storable_unbounded: deserialize failed: {err}");
89 })
90 }
91 }
92 };
93}