codama_attributes/
unsupported_attribute.rs1use crate::Attribute;
2use codama_errors::CodamaError;
3
4#[derive(Debug, PartialEq)]
5pub struct UnsupportedAttribute<'a> {
6 pub ast: &'a syn::Attribute,
7}
8
9impl<'a> UnsupportedAttribute<'a> {
10 pub fn new(ast: &'a syn::Attribute) -> Self {
11 Self { ast }
12 }
13}
14
15impl<'a> TryFrom<&'a Attribute<'a>> for &'a UnsupportedAttribute<'a> {
16 type Error = CodamaError;
17
18 fn try_from(attribute: &'a Attribute) -> Result<Self, Self::Error> {
19 match attribute {
20 Attribute::Unsupported(a) => Ok(a),
21 _ => Err(CodamaError::InvalidAttribute {
22 expected: "unsupported".to_string(),
23 actual: attribute.name(),
24 }),
25 }
26 }
27}