use macro_tools :: { Result, syn };
use macro_tools :: { AttributePropertyOptionalSingletone };
#[ derive( Debug, Default ) ]
pub struct FieldAttributes
{
pub skip: AttributePropertyOptionalSingletone,
pub enabled: AttributePropertyOptionalSingletone,
pub debug: AttributePropertyOptionalSingletone,
pub on: AttributePropertyOptionalSingletone,
}
impl FieldAttributes
{
pub fn from_attrs< 'a >(attrs: impl Iterator< Item = &'a syn ::Attribute >) -> Result< Self >
where
Self: Sized,
{
let mut result = Self ::default();
for attr in attrs
{
if attr.path().is_ident("from")
{
attr.parse_nested_meta(|meta| {
if meta.path.is_ident("on")
{
result.on = AttributePropertyOptionalSingletone ::from(true);
} else if meta.path.is_ident("debug")
{
result.debug = AttributePropertyOptionalSingletone ::from(true);
} else if meta.path.is_ident("enabled")
{
result.enabled = AttributePropertyOptionalSingletone ::from(true);
} else if meta.path.is_ident("skip")
{
result.skip = AttributePropertyOptionalSingletone ::from(true);
} else {
}
Ok(())
})?;
} else {
}
}
Ok(result)
}
}