Skip to main content

hydro_lang/compile/
mod.rs

1//! Hydro compilation: the Hydro IR, Hydro to DFIR translation, and traits for deployment targets.
2
3#[expect(missing_docs, reason = "TODO")]
4pub mod ir;
5
6#[cfg(feature = "build")]
7#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
8#[expect(missing_docs, reason = "TODO")]
9pub mod built;
10
11#[cfg(feature = "build")]
12#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
13#[expect(missing_docs, reason = "TODO")]
14pub mod compiled;
15
16#[cfg(feature = "build")]
17#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
18#[expect(missing_docs, reason = "TODO")]
19pub mod deploy;
20
21#[cfg(feature = "build")]
22#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
23pub mod embedded;
24
25pub mod embedded_runtime;
26
27#[cfg(feature = "build")]
28#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
29#[expect(missing_docs, reason = "TODO")]
30pub mod deploy_provider;
31
32#[expect(missing_docs, reason = "TODO")]
33pub mod builder;
34
35#[cfg(stageleft_runtime)]
36#[cfg(feature = "trybuild")]
37#[cfg_attr(docsrs, doc(cfg(feature = "trybuild")))]
38#[expect(missing_docs, reason = "TODO")]
39#[cfg_attr(
40    not(any(feature = "deploy", feature = "sim", feature = "maelstrom")),
41    expect(
42        dead_code,
43        reason = "\"trybuild\" feature should be enabled by \"deploy\" / \"sim\" / \"maelstrom\""
44    )
45)]
46pub mod trybuild;
47
48#[cfg(stageleft_runtime)]
49#[cfg(feature = "trybuild")]
50#[cfg_attr(docsrs, doc(cfg(feature = "trybuild")))]
51pub use trybuild::generate::init_test;
52
53/// Ident used for the DFIR runtime instance variable name.
54#[cfg(feature = "build")]
55#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
56pub(crate) const DFIR_IDENT: &str = "flow";
57
58/// Returns the `dfir_rs::scheduled::metrics::MetricsState` typestate type that the DFIR codegen
59/// will use for the generated `Dfir`'s `Context`, based on
60/// [`AsCodeOptions::include_metrics_tracking`](dfir_lang::graph::AsCodeOptions::include_metrics_tracking).
61///
62/// This must match the type chosen by `DfirGraph::as_code_with_options`, and is used to reveal the
63/// `Metrics` associated type in generated `Dfir<impl TickClosure<Metrics = ...>>` signatures so
64/// callers can access `Dfir::metrics()` when (and only when) tracking is enabled.
65#[cfg(feature = "build")]
66pub(crate) fn dfir_metrics_state_type(
67    as_code_options: &dfir_lang::graph::AsCodeOptions,
68    root: &proc_macro2::TokenStream,
69) -> proc_macro2::TokenStream {
70    if as_code_options.include_metrics_tracking {
71        quote::quote! { #root::runtime_support::dfir_rs::scheduled::metrics::DfirMetrics }
72    } else {
73        quote::quote! { () }
74    }
75}