codama_koroks/
unsupported_item_korok.rs

1use crate::KorokTrait;
2use codama_attributes::Attributes;
3use codama_errors::CodamaResult;
4use codama_nodes::Node;
5use codama_syn_helpers::extensions::*;
6
7#[derive(Debug, PartialEq)]
8pub struct UnsupportedItemKorok<'a> {
9    pub ast: &'a syn::Item,
10    pub attributes: Attributes<'a>,
11    pub node: Option<Node>,
12}
13
14impl<'a> UnsupportedItemKorok<'a> {
15    pub fn parse(ast: &'a syn::Item) -> CodamaResult<Self> {
16        let attributes = match ast.attributes() {
17            Some(attrs) => Attributes::parse(attrs, ast.into())?,
18            None => Attributes(Vec::new()),
19        };
20        Ok(Self {
21            ast,
22            attributes,
23            node: None,
24        })
25    }
26}
27
28impl KorokTrait for UnsupportedItemKorok<'_> {
29    fn node(&self) -> &Option<Node> {
30        &self.node
31    }
32
33    fn set_node(&mut self, node: Option<Node>) {
34        self.node = node;
35    }
36
37    fn attributes(&self) -> Option<&Attributes> {
38        Some(&self.attributes)
39    }
40}