1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![warn(missing_docs)]
3
4stageleft::stageleft_no_entry_crate!();
16
17#[cfg(feature = "runtime_support")]
18#[cfg_attr(docsrs, doc(cfg(feature = "runtime_support")))]
19#[doc(hidden)]
20pub mod runtime_support {
21 #[cfg(feature = "sim")]
22 pub use colored;
23 #[cfg(feature = "deploy_integration")]
24 pub use hydro_deploy_integration;
25 pub use {bincode, dfir_rs, stageleft, tokio};
26
27 #[cfg(any(feature = "deploy_integration", feature = "docker_runtime"))]
28 pub mod launch;
29}
30
31#[doc(hidden)]
32pub mod macro_support {
33 pub use copy_span;
34}
35
36pub mod prelude {
37 pub use stageleft::q;
49
50 pub use crate::compile::builder::FlowBuilder;
51 pub use crate::live_collections::boundedness::{Bounded, Unbounded};
52 pub use crate::live_collections::keyed_singleton::KeyedSingleton;
53 pub use crate::live_collections::keyed_stream::KeyedStream;
54 pub use crate::live_collections::optional::Optional;
55 pub use crate::live_collections::singleton::Singleton;
56 pub use crate::live_collections::sliced::sliced;
57 pub use crate::live_collections::stream::Stream;
58 pub use crate::location::{Cluster, External, Location as _, Process, Tick};
59 pub use crate::networking::TCP;
60 pub use crate::nondet::{NonDet, nondet};
61 pub use crate::properties::ManualProof;
62
63 #[macro_export]
65 macro_rules! setup {
66 () => {
67 stageleft::stageleft_no_entry_crate!();
68
69 #[cfg(test)]
70 mod test_init {
71 #[ctor::ctor]
72 fn init() {
73 $crate::compile::init_test();
74 }
75 }
76 };
77 }
78}
79
80#[cfg(feature = "dfir_context")]
81#[cfg_attr(docsrs, doc(cfg(feature = "dfir_context")))]
82pub mod runtime_context;
83
84pub mod nondet;
85
86pub mod live_collections;
87
88pub mod location;
89
90pub mod networking;
91
92pub mod properties;
93
94pub mod telemetry;
95
96#[cfg(any(
97 feature = "deploy",
98 feature = "deploy_integration" ))]
100#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
101pub mod deploy;
102
103#[cfg(feature = "sim")]
104#[cfg_attr(docsrs, doc(cfg(feature = "sim")))]
105pub mod sim;
106
107pub mod forward_handle;
108
109pub mod compile;
110
111mod manual_expr;
112
113#[cfg(stageleft_runtime)]
114#[cfg(feature = "viz")]
115#[cfg_attr(docsrs, doc(cfg(feature = "viz")))]
116#[expect(missing_docs, reason = "TODO")]
117pub mod viz;
118
119mod staging_util;
120
121#[cfg(feature = "deploy")]
122#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
123pub mod test_util;
124
125#[cfg(feature = "build")]
126#[ctor::ctor]
127fn init_rewrites() {
128 stageleft::add_private_reexport(
129 vec!["tokio_util", "codec", "lines_codec"],
130 vec!["tokio_util", "codec"],
131 );
132}
133
134#[cfg(all(test, feature = "trybuild"))]
135mod test_init {
136 #[ctor::ctor]
137 fn init() {
138 crate::compile::init_test();
139 }
140}
141
142#[doc(hidden)]
155#[macro_export]
156macro_rules! newtype_counter {
157 (
158 $(
159 $( #[$attr:meta] )*
160 $vis:vis struct $name:ident($typ:ty);
161 )*
162 ) => {
163 $(
164 $( #[$attr] )*
165 #[repr(transparent)]
166 #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
167 $vis struct $name($typ);
168
169 #[allow(clippy::allow_attributes, dead_code, reason = "macro-generated methods may be unused")]
170 impl $name {
171 pub fn get_and_increment(&mut self) -> Self {
173 let id = self.0;
174 self.0 += 1;
175 Self(id)
176 }
177
178 pub fn range_up_to(&self) -> impl std::iter::DoubleEndedIterator<Item = Self>
182 + std::iter::FusedIterator
183 {
184 (0..self.0).map(Self)
185 }
186
187 pub fn into_inner(self) -> $typ {
189 self.0
190 }
191 }
192
193 impl std::fmt::Display for $name {
194 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
195 write!(f, "{}", self.0)
196 }
197 }
198
199 impl serde::ser::Serialize for $name {
200 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
201 where
202 S: serde::Serializer
203 {
204 serde::ser::Serialize::serialize(&self.0, serializer)
205 }
206 }
207
208 impl<'de> serde::de::Deserialize<'de> for $name {
209 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
210 where
211 D: serde::Deserializer<'de>
212 {
213 serde::de::Deserialize::deserialize(deserializer).map(Self)
214 }
215 }
216 )*
217 };
218}