gir_parser/
member.rs

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