radix_common/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![recursion_limit = "256"] // Enables certain tests of deep typed SBOR to function
3
4#[cfg(not(any(feature = "std", feature = "alloc")))]
5compile_error!("Either feature `std` or `alloc` must be enabled for this crate.");
6#[cfg(all(feature = "std", feature = "alloc"))]
7compile_error!("Feature `std` and `alloc` can't be enabled at the same time.");
8
9/// RE bech32 address library.
10pub mod address;
11/// RE protocol constants
12pub mod constants;
13/// RE crypto library
14pub mod crypto;
15/// RE scrypto data model.
16pub mod data;
17/// RE math library.
18pub mod math;
19/// RE network identifier model.
20pub mod network;
21/// Common models for state changes in RE
22pub mod state;
23/// RE time library.
24pub mod time;
25/// RE types.
26pub mod types;
27
28pub mod traits;
29
30mod macros;
31
32// Re-export SBOR derive.
33extern crate sbor;
34pub use sbor::{Categorize, Decode, Encode, Sbor};
35
36// Re-export radix engine derive.
37extern crate radix_sbor_derive;
38pub use radix_sbor_derive::{
39    ManifestCategorize, ManifestDecode, ManifestEncode, ManifestSbor, ScryptoCategorize,
40    ScryptoDecode, ScryptoEncode, ScryptoEvent, ScryptoSbor, ScryptoSborAssertion,
41};
42
43// extern crate self as X; in lib.rs allows ::X and X to resolve to this crate inside this crate.
44// This enables procedural macros which output code involving paths to this crate, to work inside
45// this crate. See this link for details:
46// https://users.rust-lang.org/t/how-can-i-use-my-derive-macro-from-the-crate-that-declares-the-trait/60502
47//
48// IMPORTANT:
49// This should never be pub, else `X::X::X::X::...` becomes a valid path in downstream crates,
50// which we've discovered can cause really bad autocomplete times (when combined with other
51// specific imports, generic traits, resolution paths which likely trigger edge cases in
52// Rust Analyzer which get stuck on these infinite possible paths)
53extern crate self as radix_common;
54
55/// Each module should have its own prelude, which:
56/// * Adds preludes of upstream crates
57/// * Exports types with specific-enough names which mean they can safely be used downstream.
58///
59/// The idea is that we can just include the current crate's prelude and avoid messing around with tons of includes.
60/// This makes refactors easier, and makes integration into the node less painful.
61pub mod prelude {
62    // Exports from upstream libraries
63    pub use radix_sbor_derive::{
64        ManifestCategorize, ManifestDecode, ManifestEncode, ManifestSbor, ScryptoCategorize,
65        ScryptoDecode, ScryptoDescribe, ScryptoEncode, ScryptoEvent, ScryptoSbor,
66        ScryptoSborAssertion,
67    };
68    pub use sbor::prelude::*;
69    pub use sbor::*;
70
71    // Exports from this crate
72    pub use super::address::*;
73    pub use super::constants::*;
74    pub use super::crypto::*;
75    pub use super::data::manifest::prelude::*;
76    pub use super::data::scrypto::prelude::*;
77    pub use super::math::*;
78    pub use super::network::*;
79    pub use super::state::*;
80    pub use super::time::*;
81    pub use super::traits::*;
82    pub use super::types::*;
83    pub use crate::{
84        define_wrapped_hash, i, manifest_args, scrypto_args, to_manifest_value_and_unwrap,
85    };
86}
87
88pub(crate) mod internal_prelude {
89    pub use super::prelude::*;
90    pub use sbor::representations::*;
91    pub use sbor::traversal::*;
92}