omnia_guest_macro/lib.rs
1#![doc = include_str!("../README.md")]
2
3//! Procedural macros for the omnia guest.
4
5#![forbid(unsafe_code)]
6
7mod guest;
8mod http;
9mod messaging;
10
11use proc_macro::TokenStream;
12use syn::parse_macro_input;
13
14/// Generates the guest infrastructure based on the specified configuration.
15///
16/// # Example
17///
18/// ```rust,ignore
19/// guest_macro::guest!({
20/// owner: "at",
21/// provider: MyProvider,
22/// http: [
23/// "/some/get/path": get(SomeRequest, SomeResponse),
24/// "/some/other-get/path": get(SomeRequest with_query, SomeResponse),
25/// "/some/post/path": post(SomeRequest, SomeResponse),
26/// "/some/post-body/path": post(SomeRequest with_body, SomeResponse),
27/// ],
28/// messaging: [
29/// "topic-name.v1": TopicMessage,
30/// "other-topic.v2": OtherTopicMessage,
31/// ]
32/// });
33/// ```
34#[proc_macro]
35pub fn guest(input: TokenStream) -> TokenStream {
36 let config = parse_macro_input!(input as guest::Config);
37 guest::expand(&config).into()
38}