ligen_ir/
interface.rs

1use crate::{Attributes, Object, Function, Identifier, Method, Path, Visibility};
2use crate::prelude::*;
3
4#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct Interface {
6    /// Interface attributes.
7    pub attributes: Attributes,
8    /// Interface visibility.
9    pub visibility: Visibility,
10    /// Interface identifier.
11    pub identifier: Identifier,
12    /// Interface objects.
13    pub objects: Vec<Object>,
14    /// Public functions.
15    pub functions: Vec<Function>,
16    /// Interface methods.
17    pub methods: Vec<Method>,
18    /// Interfaces that this interface extends.
19    pub interfaces: Vec<Path>
20}
21
22impl CountSymbols for &Vec<Interface> {
23    fn count_symbols(&self) -> usize {
24        self.iter().fold(0, |acc, interface| acc + interface.count_symbols())
25    }
26}
27
28impl CountSymbols for Vec<Interface> {
29    fn count_symbols(&self) -> usize {
30        self.iter().fold(0, |acc, interface| acc + interface.count_symbols())
31    }
32}
33
34impl CountSymbols for &Interface {
35    fn count_symbols(&self) -> usize {
36        self.objects.count_symbols()
37            + self.functions.count_symbols()
38            + self.methods.count_symbols()
39    }
40}
41
42impl CountSymbols for Interface {
43    fn count_symbols(&self) -> usize {
44        self.objects.count_symbols()
45            + self.functions.count_symbols()
46            + self.methods.count_symbols()
47    }
48}