Skip to main content

omnia_runtime_macro/
lib.rs

1#![doc = include_str!("../README.md")]
2
3//! Procedural macros for the omnia runtime.
4
5#![forbid(unsafe_code)]
6
7mod expand;
8mod runtime;
9
10use proc_macro::TokenStream;
11use syn::parse_macro_input;
12
13/// Generates the runtime infrastructure based on the configuration.
14///
15/// # Example
16///
17/// ```rust,ignore
18/// omnia::runtime!({
19///     omnia_wasi_http: WasiHttp,
20///     omnia_wasi_otel: DefaultOtel,
21///     omnia_wasi_blobstore: MongoDb,
22/// });
23/// ```
24#[proc_macro]
25pub fn runtime(input: TokenStream) -> TokenStream {
26    let parsed = parse_macro_input!(input as runtime::Config);
27    match expand::expand(&parsed) {
28        Ok(ts) => ts.into(),
29        Err(e) => e.into_compile_error().into(),
30    }
31}