From 988dbaff062487024113035c9bccf4f9d5c8a763 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 18:44:40 +0100 Subject: [PATCH] config macros: Provide `per_client` and `global` attrs These set the SKL explicitly. Signed-off-by: Ian Jackson --- macros/macros.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/macros/macros.rs b/macros/macros.rs index 1233b41..b6d4bf3 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -21,6 +21,7 @@ use itertools::Itertools; /// /// * `limited`, `server`, `client`: cooked sets of settings; /// default `SKL` is `PerClient` except for `limited` +/// * `global` and `per_client`: set the SKL. /// * `special(method, SKL)` /// /// Generated code @@ -44,7 +45,8 @@ use itertools::Itertools; /// } /// ``` #[proc_macro_derive(ResolveConfig, attributes( - limited, server, client, computed, special + limited, server, client, computed, special, + per_client, global, ))] pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); @@ -67,6 +69,14 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { for attr in &field.attrs { let atspan = attr.path.segments.last().unwrap().ident.span(); if attr.tokens.is_empty() { + if &attr.path == &parse_quote!{ per_client } { + skl = Some(quote_spanned!{fname_span=> SectionKindList::PerClient }); + continue; + } else if &attr.path == &parse_quote!{ global } { + skl = Some(quote_spanned!{fname_span=> + SectionKindList::Global }); + continue; + } method = attr.path.to_token_stream(); if &attr.path == &parse_quote!{ limited } { skl = Some(quote_spanned!{atspan=> SectionKindList::Limited }); -- 2.30.2