1use xmlserde_derives::XmlDeserialize;
2
3use crate::{
4 attribute::Attribute,
5 callback::Callback,
6 class::Implements,
7 constant::Constant,
8 documentation::{DocDeprecated, DocStability, DocVersion, Documentation, SourcePosition},
9 field::Field,
10 function::{Function, FunctionInline},
11 method::{Method, MethodInline},
12 prelude::*,
13 property::Property,
14 signal::Signal,
15 version::Version,
16 virtual_method::VirtualMethod,
17 Record, Stability, Union,
18};
19
20#[derive(Clone, Debug, XmlDeserialize)]
21#[xmlserde(root = b"prerequisite")]
22#[xmlserde(deny_unknown_fields)]
23pub struct Prerequisite {
24 #[xmlserde(name = b"name", ty = "attr")]
25 name: String,
26}
27
28impl Prerequisite {
29 pub fn name(&self) -> &str {
30 &self.name
31 }
32}
33
34#[derive(Clone, Debug, XmlDeserialize)]
35#[allow(clippy::large_enum_variant)]
38pub enum InterfaceField {
39 #[xmlserde(name = b"field")]
40 Field(Field),
41 #[xmlserde(name = b"union")]
42 Union(Union),
43 #[xmlserde(name = b"record")]
44 Record(Record),
45 #[xmlserde(name = b"callback")]
46 Callback(Callback),
47}
48
49#[derive(Clone, Debug, XmlDeserialize)]
50#[xmlserde(root = b"interface")]
51#[xmlserde(deny_unknown_fields)]
52pub struct Interface {
53 #[xmlserde(name = b"name", ty = "attr")]
54 name: String,
55 #[xmlserde(name = b"c:symbol-prefix", ty = "attr")]
56 symbol_prefix: Option<String>,
57 #[xmlserde(name = b"c:type", ty = "attr")]
58 c_type: Option<String>,
59 #[xmlserde(name = b"glib:type-name", ty = "attr")]
60 g_type_name: String,
61 #[xmlserde(name = b"glib:get-type", ty = "attr")]
62 g_get_type: String,
63 #[xmlserde(name = b"glib:type-struct", ty = "attr")]
64 g_type_struct: Option<String>,
65 #[xmlserde(name = b"introspectable", ty = "attr")]
67 introspectable: Option<bool>,
68 #[xmlserde(name = b"deprecated", ty = "attr")]
69 deprecated: Option<bool>,
70 #[xmlserde(name = b"version", ty = "attr")]
71 version: Option<Version>,
72 #[xmlserde(name = b"deprecated-version", ty = "attr")]
73 deprecated_version: Option<Version>,
74 #[xmlserde(name = b"stability", ty = "attr")]
75 stability: Option<Stability>,
76 #[xmlserde(name = b"doc", ty = "child")]
78 doc: Option<Documentation>,
79 #[xmlserde(name = b"doc-deprecated", ty = "child")]
80 doc_deprecated: Option<DocDeprecated>,
81 #[xmlserde(name = b"doc-stability", ty = "child")]
82 doc_stability: Option<DocStability>,
83 #[xmlserde(name = b"doc-version", ty = "child")]
84 doc_version: Option<DocVersion>,
85 #[xmlserde(name = b"source-position", ty = "child")]
86 source_position: Option<SourcePosition>,
87 #[xmlserde(name = b"attribute", ty = "child")]
89 attributes: Vec<Attribute>,
90
91 #[xmlserde(name = b"prerequisite", ty = "child")]
92 prerequisites: Vec<Prerequisite>,
93
94 #[xmlserde(name = b"implements", ty = "child")]
95 implements: Vec<Implements>,
96
97 #[xmlserde(name = b"function", ty = "child")]
98 functions: Vec<Function>,
99
100 #[xmlserde(name = b"function-inline", ty = "child")]
101 inline_functions: Vec<FunctionInline>,
102
103 #[xmlserde(name = b"constructor", ty = "child")]
104 constructors: Vec<Function>,
105
106 #[xmlserde(name = b"method", ty = "child")]
107 methods: Vec<Method>,
108
109 #[xmlserde(name = b"inline-methods", ty = "child")]
110 inline_methods: Vec<MethodInline>,
111
112 #[xmlserde(name = b"virtual-method", ty = "child")]
113 virtual_methods: Vec<VirtualMethod>,
114
115 #[xmlserde(ty = "untag")]
116 fields: Vec<InterfaceField>,
117
118 #[xmlserde(name = b"property", ty = "child")]
119 properties: Vec<Property>,
120
121 #[xmlserde(name = b"glib:signal", ty = "child")]
122 signals: Vec<Signal>,
123
124 #[xmlserde(name = b"constant", ty = "child")]
125 constants: Vec<Constant>,
126}
127
128impl Interface {
129 pub fn name(&self) -> &str {
130 &self.name
131 }
132
133 pub fn symbol_prefix(&self) -> Option<&str> {
134 self.symbol_prefix.as_deref()
135 }
136
137 pub fn c_type(&self) -> Option<&str> {
138 self.c_type.as_deref()
139 }
140
141 pub fn g_type_name(&self) -> &str {
142 &self.g_type_name
143 }
144
145 pub fn g_get_type(&self) -> &str {
146 &self.g_get_type
147 }
148
149 pub fn g_type_struct(&self) -> Option<&str> {
150 self.g_type_struct.as_deref()
151 }
152
153 pub fn prerequisites(&self) -> &[Prerequisite] {
154 &self.prerequisites
155 }
156
157 pub fn implements(&self) -> &[Implements] {
158 &self.implements
159 }
160
161 pub fn constructors(&self) -> &[Function] {
162 &self.constructors
163 }
164
165 pub fn methods(&self) -> &[Method] {
166 &self.methods
167 }
168
169 pub fn inlined_methods(&self) -> &[MethodInline] {
170 &self.inline_methods
171 }
172
173 pub fn functions(&self) -> &[Function] {
174 &self.functions
175 }
176
177 pub fn inlined_functions(&self) -> &[FunctionInline] {
178 &self.inline_functions
179 }
180
181 pub fn virtual_methods(&self) -> &[VirtualMethod] {
182 &self.virtual_methods
183 }
184
185 pub fn fields(&self) -> &[InterfaceField] {
186 &self.fields
187 }
188
189 pub fn properties(&self) -> &[Property] {
190 &self.properties
191 }
192
193 pub fn signals(&self) -> &[Signal] {
194 &self.signals
195 }
196
197 pub fn constants(&self) -> &[Constant] {
198 &self.constants
199 }
200}
201
202impl_documentable!(Interface);
203impl_attributable!(Interface);
204impl_info!(Interface);