dimas_macros/
lib.rs

1// Copyright © 2024 Stephan Kunz
2
3//! `#[main(...)]` macro for `DiMAS`
4//!
5
6extern crate proc_macro;
7
8mod r#impl;
9
10use proc_macro::TokenStream;
11
12/// Marks async main functions to be executed by a multi threaded tokio runtime
13///
14/// Note: This macro can only be used on the `main` function.
15///
16/// # Usage
17/// ```no_test
18/// #[dimas::main]
19/// async fn main() {
20///     // your code
21///     ...
22/// }
23/// ```
24///
25/// ## Increase Worker threads
26/// `DiMAS` creates a minimum of 3 worker threads within tokio runtime.
27///
28/// To increase the amount of worker threads, the macro can be configured using
29///
30/// ```no_test
31/// #[dimas::main(additional_threads = 5)]  // adds additional 5 threads to the default of 3
32/// ```
33///
34#[proc_macro_attribute]
35pub fn main(metadata: TokenStream, input: TokenStream) -> TokenStream {
36	// call implementation with conversion to and from proc-macro2 library
37	r#impl::main(metadata.into(), input.into()).into()
38}