1use xmlserde_derives::XmlDeserialize;
2
3use crate::{
4 attribute::Attribute,
5 documentation::{DocDeprecated, DocStability, DocVersion, Documentation, SourcePosition},
6 prelude::*,
7 r#type::AnyType,
8 version::Version,
9 Stability,
10};
11
12#[derive(Clone, Debug, XmlDeserialize)]
13#[xmlserde(root = b"constant")]
14#[xmlserde(deny_unknown_fields)]
15pub struct Constant {
16 #[xmlserde(name = b"name", ty = "attr")]
17 name: String,
18 #[xmlserde(name = b"value", ty = "attr")]
19 value: String,
20 #[xmlserde(name = b"c:type", ty = "attr")]
21 c_type: Option<String>,
22 #[xmlserde(name = b"c:identifier", ty = "attr")]
23 c_identifier: Option<String>,
24 #[xmlserde(name = b"introspectable", ty = "attr")]
26 introspectable: Option<bool>,
27 #[xmlserde(name = b"deprecated", ty = "attr")]
28 deprecated: Option<bool>,
29 #[xmlserde(name = b"version", ty = "attr")]
30 version: Option<Version>,
31 #[xmlserde(name = b"deprecated-version", ty = "attr")]
32 deprecated_version: Option<Version>,
33 #[xmlserde(name = b"stability", ty = "attr")]
34 stability: Option<Stability>,
35 #[xmlserde(name = b"doc", ty = "child")]
37 doc: Option<Documentation>,
38 #[xmlserde(name = b"doc-deprecated", ty = "child")]
39 doc_deprecated: Option<DocDeprecated>,
40 #[xmlserde(name = b"doc-stability", ty = "child")]
41 doc_stability: Option<DocStability>,
42 #[xmlserde(name = b"doc-version", ty = "child")]
43 doc_version: Option<DocVersion>,
44 #[xmlserde(name = b"source-position", ty = "child")]
45 source_position: Option<SourcePosition>,
46 #[xmlserde(name = b"attribute", ty = "child")]
48 attributes: Vec<Attribute>,
49 #[xmlserde(name = b"type", ty = "child")]
50 type_: AnyType,
51}
52
53impl Constant {
54 pub fn name(&self) -> &str {
55 &self.name
56 }
57
58 pub fn value(&self) -> &str {
59 &self.value
60 }
61
62 pub fn c_type(&self) -> Option<&str> {
63 self.c_type.as_deref()
64 }
65
66 pub fn c_identifier(&self) -> Option<&str> {
67 self.c_identifier.as_deref()
68 }
69
70 pub fn ty(&self) -> &AnyType {
71 &self.type_
72 }
73}
74
75impl_info!(Constant);
76impl_attributable!(Constant);
77impl_documentable!(Constant);