1#![doc = include_str!("../README.md")]
2#![warn(
3 elided_lifetimes_in_paths,
4 missing_debug_implementations,
5 missing_docs,
6 unsafe_op_in_unsafe_fn,
7 clippy::undocumented_unsafe_blocks,
8 clippy::missing_safety_doc
9)]
10#![cfg_attr(docsrs, feature(doc_cfg))]
11
12#[cfg(target_feature = "atomics")]
13compile_error!("This version of the CDK does not support multithreading.");
14
15pub mod api;
16pub mod bitcoin_canister;
17pub mod call;
18pub mod futures;
19mod macros;
20pub mod management_canister;
21mod printer;
22pub mod stable;
23pub mod storage;
24
25use std::sync::Once;
26
27#[doc(inline)]
28pub use api::trap;
29
30#[doc(inline)]
31#[allow(deprecated)]
32pub use api::{
33 call::{call, notify},
34 caller, id, print,
35};
36
37#[doc(inline)]
38pub use macros::*;
39
40static SETUP: Once = Once::new();
41
42fn setup() {
44 SETUP.call_once(printer::hook);
45}
46
47#[cfg(target_family = "wasm")]
49#[macro_export]
50macro_rules! println {
51 ($fmt:expr) => ($crate::api::debug_print(format!($fmt)));
52 ($fmt:expr, $($arg:tt)*) => ($crate::api::debug_print(format!($fmt, $($arg)*)));
53}
54
55#[cfg(not(target_family = "wasm"))]
57#[macro_export]
58macro_rules! println {
59 ($fmt:expr) => (std::println!($fmt));
60 ($fmt:expr, $($arg:tt)*) => (std::println!($fmt, $($arg)*));
61}
62
63#[cfg(target_family = "wasm")]
65#[macro_export]
66macro_rules! eprintln {
67 ($fmt:expr) => ($crate::api::debug_print(format!($fmt)));
68 ($fmt:expr, $($arg:tt)*) => ($crate::api::debug_print(format!($fmt, $($arg)*)));
69}
70
71#[cfg(not(target_family = "wasm"))]
73#[macro_export]
74macro_rules! eprintln {
75 ($fmt:expr) => (std::eprintln!($fmt));
76 ($fmt:expr, $($arg:tt)*) => (std::eprintln!($fmt, $($arg)*));
77}