From: Ian Jackson Date: Sat, 24 Jul 2021 11:56:54 +0000 (+0100) Subject: config, wip parsing X-Git-Tag: hippotat/1.0.0~488 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=a235044882130ab26a9266a87a84a6c0dac9cf86;p=hippotat.git config, wip parsing Signed-off-by: Ian Jackson --- diff --git a/macros/macros.rs b/macros/macros.rs index d0045f5..593f739 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -32,7 +32,7 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let mut names = vec![]; let mut output = vec![]; for field in &fields.named { - dbg!(field); + //dbg!(field); let fname = &field.ident.as_ref().unwrap(); let fname_span = fname.span(); let mut skl = quote_spanned!{fname_span=> SectionKindList::Ordinary }; @@ -66,13 +66,13 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { names.push(quote!{ (#fname_lit, #skl), }); - dbg!(&method); + //dbg!(&method); output.push(quote!{ #fname: rctx. #method ( #fname_lit )?, }); - eprintln!("{:?} method={:?} skl={:?}", field.ident, method, skl); + //eprintln!("{:?} method={:?} skl={:?}", field.ident, method, skl); } - dbg!(&output); + //dbg!(&output); let output = quote! { impl #target { @@ -88,6 +88,6 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { } } }; - eprintln!("{}", &output); + //eprintln!("{}", &output); output.into() } diff --git a/src/config.rs b/src/config.rs index e7b7783..7a1f518 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,7 +34,6 @@ pub struct InstanceConfig { // Capped settings: */ #[limited] pub max_batch_down: u32, -/* #[limited] pub max_queue_time: Duration, #[limited] pub http_timeout: Duration, #[limited] pub target_requests_outstanding: u32, @@ -59,7 +58,6 @@ pub struct InstanceConfig { #[client] pub http_retry: Duration, #[client] pub url: Uri, #[client] pub vroutes: Vec, -*/ } #[derive(Debug,Clone,Hash,Eq,PartialEq)] @@ -290,6 +288,18 @@ macro_rules! parseable_from_str { ($t:ty) => { } } } parseable_from_str!{u32} +parseable_from_str!{IpAddr} + +impl Parseable for Vec { + #[throws(AE)] + fn parse(s: &Option) -> Vec { + let s = s.as_ref().ok_or_else(|| anyhow!("value needed"))?; + s.split_ascii_whitespace() + .map(|s| s.parse()) + .collect::>>()? + } +} + #[derive(Debug,Copy,Clone)] enum SectionKindList {