diff --git a/apb/src/macros.rs b/apb/src/macros.rs index 3acd72ef..04cdd615 100644 --- a/apb/src/macros.rs +++ b/apb/src/macros.rs @@ -115,6 +115,12 @@ macro_rules! getter { } }; + ($name:ident::$rename:ident -> bool) => { + fn $name(&self) -> Option { + self.get(stringify!($rename))?.as_bool() + } + }; + ($name:ident::$rename:ident -> &str) => { fn $name(&self) -> Option<&str> { self.get(stringify!($rename))?.as_str() @@ -206,6 +212,17 @@ macro_rules! setter { } }; + ($name:ident::$rename:ident -> bool) => { + paste::item! { + fn [< set_$name >](mut self, val: Option) -> Self { + $crate::macros::set_maybe_value( + &mut self, stringify!($rename), val.map(|x| serde_json::Value::Bool(x)) + ); + self + } + } + }; + ($name:ident -> &str) => { paste::item! { fn [< set_$name >](mut self, val: Option<&str>) -> Self {