Skip to main content

ic_cdk/
lib.rs

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 call;
17pub mod futures;
18mod macros;
19pub mod stable;
20pub mod storage;
21
22#[doc(inline)]
23pub use api::trap;
24
25#[doc(inline)]
26pub use macros::*;
27
28/// Format and then print the formatted message
29#[cfg(target_family = "wasm")]
30#[macro_export]
31macro_rules! println {
32    ($fmt:expr) => ($crate::api::debug_print(format!($fmt)));
33    ($fmt:expr, $($arg:tt)*) => ($crate::api::debug_print(format!($fmt, $($arg)*)));
34}
35
36/// Format and then print the formatted message
37#[cfg(not(target_family = "wasm"))]
38#[macro_export]
39macro_rules! println {
40    ($fmt:expr) => (std::println!($fmt));
41    ($fmt:expr, $($arg:tt)*) => (std::println!($fmt, $($arg)*));
42}
43
44/// Format and then print the formatted message
45#[cfg(target_family = "wasm")]
46#[macro_export]
47macro_rules! eprintln {
48    ($fmt:expr) => ($crate::api::debug_print(format!($fmt)));
49    ($fmt:expr, $($arg:tt)*) => ($crate::api::debug_print(format!($fmt, $($arg)*)));
50}
51
52/// Format and then print the formatted message
53#[cfg(not(target_family = "wasm"))]
54#[macro_export]
55macro_rules! eprintln {
56    ($fmt:expr) => (std::eprintln!($fmt));
57    ($fmt:expr, $($arg:tt)*) => (std::eprintln!($fmt, $($arg)*));
58}