Skip to main content

borderless_runtime/
lib.rs

1pub mod db;
2pub mod error;
3
4#[cfg(feature = "http")]
5pub mod http;
6
7mod rt;
8
9pub use error::{Error, Result};
10
11#[cfg(feature = "contracts")]
12pub use rt::contract::{
13    MutLock as ContractLock, Runtime as ContractRuntime, SharedRuntime as SharedContractRuntime,
14};
15
16#[cfg(feature = "agents")]
17pub use rt::agent::{
18    MutLock as AgentLock, Runtime as AgentRuntime, SharedRuntime as SharedAgentRuntime,
19};
20
21// Forward module content
22#[cfg(any(feature = "contracts", feature = "agents"))]
23pub use rt::*;
24
25/// Sub-Database for all contract related data
26pub const CONTRACT_SUB_DB: &str = "contract-db";
27
28/// Sub-Database for all agent related data
29pub const AGENT_SUB_DB: &str = "agent-db";
30
31/// Sub-Database, where the wasm code is stored
32pub const WASM_CODE_SUB_DB: &str = "wasm-code-db";
33
34/// Sub-Database to store the relationship between an action and a transaction
35pub const ACTION_TX_REL_SUB_DB: &str = "rel-tx-action-db";
36
37/// Sub-Database to store the relationship between contracts and agents, and vice-versa
38pub const SUBSCRIPTION_REL_SUB_DB: &str = "rel-subscription-db";
39
40/// Sub-Database, where the ledger information is stored
41pub const LEDGER_SUB_DB: &str = "ledger-db";
42
43// TODO: Tracing vs Logging !
44// We should make this toggleable via feature switch.
45
46mod log_shim {
47    #[cfg(all(feature = "tracing", not(feature = "log")))]
48    pub use tracing::{debug, error, info, trace, warn};
49
50    #[cfg(all(feature = "log", not(feature = "tracing")))]
51    pub use log::{debug, error, info, trace, warn};
52
53    // If neither logging or tracing are enabled, just send the input into the void
54    #[cfg(any(
55        all(not(feature = "log"), not(feature = "tracing")),
56        all(feature = "log", feature = "tracing")
57    ))]
58    pub use crate::void as trace;
59
60    #[cfg(any(
61        all(not(feature = "log"), not(feature = "tracing")),
62        all(feature = "log", feature = "tracing")
63    ))]
64    pub use crate::void as debug;
65
66    #[cfg(any(
67        all(not(feature = "log"), not(feature = "tracing")),
68        all(feature = "log", feature = "tracing")
69    ))]
70    pub use crate::void as info;
71
72    #[cfg(any(
73        all(not(feature = "log"), not(feature = "tracing")),
74        all(feature = "log", feature = "tracing")
75    ))]
76    pub use crate::void as warn;
77
78    #[cfg(any(
79        all(not(feature = "log"), not(feature = "tracing")),
80        all(feature = "log", feature = "tracing")
81    ))]
82    pub use crate::void as error;
83
84    #[cfg(any(
85        all(not(feature = "log"), not(feature = "tracing")),
86        all(feature = "log", feature = "tracing")
87    ))]
88    #[macro_export]
89    macro_rules! void {
90        ($($t:tt)*) => {{
91            let _ = format_args!($($t)*);
92        }};
93    }
94
95    // NOTE: We emit a compiler warning in the build.rs - which is far better than a compiler error.
96    //
97    // #[cfg(all(feature = "log", feature = "tracing"))]
98    // compile_error!("Features `log` and `tracing` are mutually exclusive.");
99}