gir_parser/
array.rs

1use xmlserde_derives::XmlDeserialize;
2
3use crate::r#type::Type;
4
5#[derive(Clone, Debug, XmlDeserialize)]
6#[xmlserde(root = b"array")]
7#[xmlserde(deny_unknown_fields)]
8pub struct Array {
9    #[xmlserde(name = b"name", ty = "attr")]
10    name: Option<String>,
11    #[xmlserde(name = b"zero-terminated", ty = "attr")]
12    zero_terminated: Option<bool>,
13    #[xmlserde(name = b"fixed-size", ty = "attr")]
14    fixed_size: Option<u16>,
15    #[xmlserde(name = b"introspectable", ty = "attr")]
16    introspectable: Option<bool>,
17    #[xmlserde(name = b"length", ty = "attr")]
18    length: Option<u32>,
19    #[xmlserde(name = b"c:type", ty = "attr")]
20    c_type: Option<String>,
21    #[xmlserde(name = b"type", ty = "child")]
22    type_: Type, // TODO: does this really has to be AnyType?
23}
24
25impl Array {
26    pub fn name(&self) -> Option<&str> {
27        self.name.as_deref()
28    }
29
30    pub fn zero_terminated(&self) -> Option<bool> {
31        self.zero_terminated
32    }
33
34    pub fn fixed_size(&self) -> Option<u16> {
35        self.fixed_size
36    }
37
38    pub fn is_introspectable(&self) -> bool {
39        self.introspectable.unwrap_or(true)
40    }
41
42    pub fn length(&self) -> Option<u32> {
43        self.length
44    }
45
46    pub fn c_type(&self) -> Option<&str> {
47        self.c_type.as_deref()
48    }
49
50    pub fn ty(&self) -> &Type {
51        &self.type_
52    }
53}