ion_proc/attribute/
property.rs

1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6
7use syn::meta::ParseNestedMeta;
8use syn::{LitStr, Result};
9
10use crate::attribute::name::Name;
11use crate::attribute::{ParseArgument as _, ParseAttribute};
12
13#[derive(Default)]
14pub(crate) struct PropertyAttribute {
15	pub(crate) name: Option<Name>,
16	pub(crate) alias: Vec<LitStr>,
17	pub(crate) skip: bool,
18	pub(crate) r#static: bool,
19}
20
21impl ParseAttribute for PropertyAttribute {
22	type Parent<'a> = ();
23
24	fn parse(&mut self, meta: &ParseNestedMeta) -> Result<bool> {
25		let success = self.name.parse_argument(meta, "name", "Property")?
26			|| self.alias.parse_argument(meta, "alias", None)?
27			|| self.skip.parse_argument(meta, "skip", "Property")?
28			|| self.r#static.parse_argument(meta, "static", "Property")?;
29
30		Ok(success)
31	}
32}