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