1use syn::Attribute;
4
5#[derive(Debug, Clone)]
6pub enum BlockFieldAttribute {
7 Input,
8 Output,
9 Parameter,
10 State,
11}
12
13impl TryFrom<&Attribute> for BlockFieldAttribute {
14 type Error = ();
15
16 fn try_from(attr: &Attribute) -> Result<Self, Self::Error> {
17 let path = attr.path();
18 if path.is_ident("input") {
19 Ok(Self::Input)
20 } else if path.is_ident("output") {
21 Ok(Self::Output)
22 } else if path.is_ident("parameter") {
23 Ok(Self::Parameter)
24 } else if path.is_ident("state") {
25 Ok(Self::State)
26 } else {
27 Err(())
28 }
29 }
30}