1use crate::TypeId;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9pub struct Global {
10 pub name: String,
12 #[serde(default, skip_serializing_if = "Vec::is_empty")]
14 pub namespace: Vec<String>,
15 #[serde(with = "crate::hex::int")]
17 #[cfg_attr(feature = "schema", schemars(with = "String"))]
18 pub rva: u32,
19 #[serde(rename = "type")]
21 pub type_id: TypeId,
22}
23
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
26#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
27pub struct Vtable {
28 pub name: String,
30 #[serde(default, skip_serializing_if = "Vec::is_empty")]
32 pub namespace: Vec<String>,
33 #[serde(with = "crate::hex::int")]
35 #[cfg_attr(feature = "schema", schemars(with = "String"))]
36 pub rva: u32,
37 #[serde(default, skip_serializing_if = "Option::is_none")]
40 pub rtti: Option<Rtti>,
41 #[serde(default)]
43 pub entries: Vec<VtableEntry>,
44}
45
46#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
49pub struct Rtti {
50 pub type_name: String,
52 #[serde(default, skip_serializing_if = "is_zero")]
55 pub offset: u32,
56}
57
58fn is_zero(value: &u32) -> bool {
59 *value == 0
60}
61
62#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
64#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
65pub struct VtableEntry {
66 pub index: u32,
68 #[serde(default, skip_serializing_if = "Option::is_none")]
70 pub name: Option<String>,
71 #[serde(with = "crate::hex::int")]
73 #[cfg_attr(feature = "schema", schemars(with = "String"))]
74 pub rva: u32,
75 #[serde(default, skip_serializing_if = "Option::is_none")]
77 pub signature: Option<TypeId>,
78}