From 39e35b6a740e235d547a70869d50f9ef0b640687 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 24 Jul 2021 14:42:21 +0100 Subject: [PATCH] config Signed-off-by: Ian Jackson --- macros/macros.rs | 23 ++++++++++++++++++++++- src/config.rs | 11 ----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/macros/macros.rs b/macros/macros.rs index 593f739..51ab23a 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -12,10 +12,31 @@ use proc_macro2::{Literal, TokenStream}; use itertools::Itertools; +/// Generates config resolver method +/// /// Atrributes: /// -/// * `limited`, `server`, `client`: cooked sets of settings +/// * `limited`, `server`, `client`: cooked sets of settings; +/// default `SKL` is `Ordinary` except for `limited` /// * `special(method, SKL)` +/// +/// Generated code +/// +/// ```no_run +/// impl<'c> ResolveContext<'c> { +/// +/// const FIELDS: &'static [(&'static str, SectionKindList)] = &[ ... ]; +/// +/// #[throws(AE)] +/// fn resolve_instance(&self) -> InstanceConfig { +/// InstanceConfig { +/// ... +/// max_batch_down: self.limited("max_batch_down")?, +/// ... +/// } +/// } +/// } +/// ``` #[proc_macro_derive(ResolveConfig, attributes( limited, server, client, special ))] diff --git a/src/config.rs b/src/config.rs index 8308285..8d9d0c8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -477,17 +477,6 @@ impl<'c> ResolveContext<'c> { } } -/* -impl<'c> ResolveContext<'c> { - #[throws(AE)] - fn resolve_instance(&self) -> InstanceConfig { - InstanceConfig { - max_batch_down: self.limited::("max_batch_down")?, - } - } -} -*/ - #[throws(AE)] pub fn read() { let opts = config::Opts::from_args(); -- 2.30.2