gir_parser/
alias.rs

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"alias")]
14#[xmlserde(deny_unknown_fields)]
15pub struct Alias {
16    #[xmlserde(name = b"name", ty = "attr")]
17    name: String,
18    #[xmlserde(name = b"c:type", ty = "attr")]
19    c_type: String,
20    // Common attributes
21    #[xmlserde(name = b"introspectable", ty = "attr")]
22    introspectable: Option<bool>,
23    #[xmlserde(name = b"deprecated", ty = "attr")]
24    deprecated: Option<bool>,
25    #[xmlserde(name = b"version", ty = "attr")]
26    version: Option<Version>,
27    #[xmlserde(name = b"deprecated-version", ty = "attr")]
28    deprecated_version: Option<Version>,
29    #[xmlserde(name = b"stability", ty = "attr")]
30    stability: Option<Stability>,
31    // Documentation
32    #[xmlserde(name = b"doc", ty = "child")]
33    doc: Option<Documentation>,
34    #[xmlserde(name = b"doc-deprecated", ty = "child")]
35    doc_deprecated: Option<DocDeprecated>,
36    #[xmlserde(name = b"doc-stability", ty = "child")]
37    doc_stability: Option<DocStability>,
38    #[xmlserde(name = b"doc-version", ty = "child")]
39    doc_version: Option<DocVersion>,
40    #[xmlserde(name = b"source-position", ty = "child")]
41    source_position: Option<SourcePosition>,
42    // Attributes: 0 or more
43    #[xmlserde(name = b"attribute", ty = "child")]
44    attributes: Vec<Attribute>,
45    #[xmlserde(ty = "untag")]
46    type_: AnyType,
47}
48
49impl Alias {
50    pub fn name(&self) -> &str {
51        &self.name
52    }
53
54    pub fn c_type(&self) -> &str {
55        &self.c_type
56    }
57
58    pub fn ty(&self) -> &AnyType {
59        &self.type_
60    }
61}
62
63impl_info!(Alias);
64impl_attributable!(Alias);
65impl_documentable!(Alias);