hydro_lang/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![warn(missing_docs)]
3
4//! Hydro is a high-level distributed programming framework for Rust.
5//! Hydro can help you quickly write scalable distributed services that are correct by construction.
6//! Much like Rust helps with memory safety, Hydro helps with [distributed safety](https://hydro.run/docs/hydro/correctness).
7//!
8//! The core Hydro API involves [live collections](https://hydro.run/docs/hydro/live-collections/), which represent asynchronously
9//! updated sources of data such as incoming network requests and application state. The most common live collection is
10//! [`live_collections::stream::Stream`]; other live collections can be found in [`live_collections`].
11//!
12//! Hydro uses a unique compilation approach where you define deployment logic as Rust code alongside your distributed system implementation.
13//! For more details on this API, see the [Hydro docs](https://hydro.run/docs/hydro/deploy/) and the [`deploy`] module.
14
15stageleft::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    pub use {bincode, dfir_rs, stageleft, tokio};
24    pub mod resource_measurement;
25}
26
27pub mod prelude {
28    // taken from `tokio`
29    //! A "prelude" for users of the `hydro_lang` crate.
30    //!
31    //! This prelude is similar to the standard library's prelude in that you'll almost always want to import its entire contents, but unlike the standard library's prelude you'll have to do so manually:
32    //! ```
33    //! # #![allow(warnings)]
34    //! use hydro_lang::prelude::*;
35    //! ```
36    //!
37    //! The prelude may grow over time as additional items see ubiquitous use.
38
39    pub use stageleft::q;
40
41    pub use crate::compile::builder::FlowBuilder;
42    pub use crate::live_collections::boundedness::{Bounded, Unbounded};
43    pub use crate::live_collections::keyed_singleton::KeyedSingleton;
44    pub use crate::live_collections::keyed_stream::KeyedStream;
45    pub use crate::live_collections::optional::Optional;
46    pub use crate::live_collections::singleton::Singleton;
47    pub use crate::live_collections::stream::Stream;
48    pub use crate::location::{Cluster, External, Location as _, Process, Tick};
49    pub use crate::nondet::{NonDet, nondet};
50}
51
52#[cfg(feature = "dfir_context")]
53#[cfg_attr(docsrs, doc(cfg(feature = "dfir_context")))]
54pub mod runtime_context;
55
56pub mod nondet;
57
58pub mod live_collections;
59
60pub mod location;
61
62#[cfg(any(
63    feature = "deploy",
64    feature = "deploy_integration" // hidden internal feature enabled in the trybuild
65))]
66#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
67pub mod deploy;
68
69#[cfg(feature = "sim")]
70#[cfg_attr(docsrs, doc(cfg(feature = "sim")))]
71pub mod sim;
72
73pub mod forward_handle;
74
75pub mod compile;
76
77mod manual_expr;
78
79#[cfg(feature = "viz")]
80#[cfg_attr(docsrs, doc(cfg(feature = "viz")))]
81#[expect(missing_docs, reason = "TODO")]
82pub mod graph;
83
84mod staging_util;
85
86#[cfg(feature = "deploy")]
87#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
88pub mod test_util;
89
90#[cfg(feature = "build")]
91#[ctor::ctor]
92fn init_rewrites() {
93    stageleft::add_private_reexport(
94        vec!["tokio_util", "codec", "lines_codec"],
95        vec!["tokio_util", "codec"],
96    );
97}
98
99#[cfg(test)]
100mod test_init {
101    #[ctor::ctor]
102    fn init() {
103        crate::deploy::init_test();
104    }
105}