ion_proc/attribute/
function.rs1use syn::meta::ParseNestedMeta;
8use syn::{Expr, Result};
9
10use crate::attribute::{ParseArgument as _, ParseAttribute};
11
12#[derive(Default)]
13pub(crate) struct ParameterAttribute {
14 pub(crate) this: bool,
15 pub(crate) convert: Option<Box<Expr>>,
16}
17
18impl ParseAttribute for ParameterAttribute {
19 type Parent<'a> = ();
20
21 fn parse(&mut self, meta: &ParseNestedMeta) -> Result<bool> {
22 let success = self.this.parse_argument(meta, "this", "Parameter")?
23 || self.convert.parse_argument(meta, "convert", "Parameter")?;
24
25 if self.this && self.convert.is_some() {
26 return Err(meta.error("Parameter with `this` attribute cannot have `convert` attributes."));
27 }
28
29 Ok(success)
30 }
31}