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    pub use {bincode, dfir_rs, stageleft, tokio};
22    pub mod resource_measurement;
23}
24
25pub mod prelude {
26    // taken from `tokio`
27    //! A "prelude" for users of the `hydro_lang` crate.
28    //!
29    //! 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:
30    //! ```
31    //! # #![allow(warnings)]
32    //! use hydro_lang::prelude::*;
33    //! ```
34    //!
35    //! The prelude may grow over time as additional items see ubiquitous use.
36
37    pub use stageleft::q;
38
39    pub use crate::compile::builder::FlowBuilder;
40    pub use crate::live_collections::boundedness::{Bounded, Unbounded};
41    pub use crate::live_collections::keyed_singleton::KeyedSingleton;
42    pub use crate::live_collections::keyed_stream::KeyedStream;
43    pub use crate::live_collections::optional::Optional;
44    pub use crate::live_collections::singleton::Singleton;
45    pub use crate::live_collections::stream::Stream;
46    pub use crate::location::{Cluster, External, Location as _, Process, Tick};
47    pub use crate::nondet::{NonDet, nondet};
48}
49
50#[cfg(feature = "dfir_context")]
51#[cfg_attr(docsrs, doc(cfg(feature = "dfir_context")))]
52pub mod runtime_context;
53
54pub mod nondet;
55
56pub mod live_collections;
57
58pub mod location;
59
60#[cfg(any(
61    feature = "deploy",
62    feature = "deploy_integration" // hidden internal feature enabled in the trybuild
63))]
64#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
65pub mod deploy;
66
67pub mod forward_handle;
68
69pub mod compile;
70
71mod manual_expr;
72
73#[cfg(feature = "viz")]
74#[cfg_attr(docsrs, doc(cfg(feature = "viz")))]
75#[expect(missing_docs, reason = "TODO")]
76pub mod graph;
77
78mod staging_util;
79
80#[cfg(feature = "deploy")]
81#[cfg_attr(docsrs, doc(cfg(feature = "deploy")))]
82pub mod test_util;
83
84#[cfg(feature = "build")]
85#[ctor::ctor]
86fn init_rewrites() {
87    stageleft::add_private_reexport(
88        vec!["tokio_util", "codec", "lines_codec"],
89        vec!["tokio_util", "codec"],
90    );
91
92    stageleft::add_private_reexport(
93        vec!["tokio_util", "codec", "bytes_codec"],
94        vec!["tokio_util", "codec"],
95    );
96
97    stageleft::add_private_reexport(vec!["bytes", "buf", "iter"], vec!["bytes", "buf"]);
98}
99
100#[cfg(test)]
101mod test_init {
102    #[ctor::ctor]
103    fn init() {
104        crate::deploy::init_test();
105    }
106}