gir_parser/
return_value.rs1use xmlserde_derives::XmlDeserialize;
2
3use crate::{
4 attribute::Attribute,
5 documentation::{DocDeprecated, DocStability, DocVersion, Documentation, SourcePosition},
6 prelude::*,
7 r#type::AnyType,
8 FunctionScope, TransferOwnership,
9};
10
11#[derive(Clone, Debug, XmlDeserialize)]
12#[xmlserde(root = b"return-value")]
13#[xmlserde(deny_unknown_fields)]
14pub struct ReturnValue {
15 #[xmlserde(name = b"introspectable", ty = "attr")]
16 introspectable: Option<bool>,
17 #[xmlserde(name = b"nullable", ty = "attr")]
18 nullable: Option<bool>,
19 #[xmlserde(name = b"closure", ty = "attr")]
20 closure: Option<usize>,
21 #[xmlserde(name = b"scope", ty = "attr")]
22 scope: Option<FunctionScope>,
23 #[xmlserde(name = b"destroy", ty = "attr")]
24 destroy: Option<usize>,
25 #[xmlserde(name = b"skip", ty = "attr")]
26 skip: Option<bool>,
27 #[xmlserde(name = b"allow-none", ty = "attr")]
28 allow_none: Option<bool>,
29
30 #[xmlserde(name = b"transfer-ownership", ty = "attr")]
31 transfer: Option<TransferOwnership>,
32
33 #[xmlserde(name = b"doc", ty = "child")]
35 doc: Option<Documentation>,
36 #[xmlserde(name = b"doc-deprecated", ty = "child")]
37 doc_deprecated: Option<DocDeprecated>,
38 #[xmlserde(name = b"doc-stability", ty = "child")]
39 doc_stability: Option<DocStability>,
40 #[xmlserde(name = b"doc-version", ty = "child")]
41 doc_version: Option<DocVersion>,
42 #[xmlserde(name = b"source-position", ty = "child")]
43 source_position: Option<SourcePosition>,
44 #[xmlserde(name = b"attribute", ty = "child")]
46 attributes: Vec<Attribute>,
47
48 #[xmlserde(name = b"type", ty = "child")]
49 type_: AnyType, }
51
52impl ReturnValue {
53 pub fn is_introspectable(&self) -> bool {
54 self.introspectable.unwrap_or(true)
55 }
56
57 pub fn is_nullable(&self) -> Option<bool> {
58 self.nullable
59 }
60
61 pub fn closure(&self) -> Option<usize> {
62 self.closure
63 }
64
65 pub fn scope(&self) -> Option<FunctionScope> {
66 self.scope
67 }
68
69 pub fn destroy(&self) -> Option<usize> {
70 self.destroy
71 }
72
73 pub fn is_skip(&self) -> Option<bool> {
74 self.skip
75 }
76
77 pub fn is_allow_none(&self) -> Option<bool> {
78 self.allow_none
79 }
80
81 pub fn transfer_ownership(&self) -> Option<TransferOwnership> {
82 self.transfer
83 }
84
85 pub fn ty(&self) -> &AnyType {
86 &self.type_
87 }
88}
89
90impl_documentable!(ReturnValue);
91impl_attributable!(ReturnValue);