dump_roblox_api/apis/dumper/
class.rs

1use serde::Deserialize;
2
3/// Dumped luau class
4#[allow(non_snake_case)]
5#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
6pub struct Class {
7    pub Members: Vec<ClassMember>,
8    pub MemoryCategory: String,
9    pub Name: String,
10    /// To get all of the Class' members,
11    /// get all of the Superclasses and
12    /// get all of their members until
13    /// the Superclass is `<<<ROOT>>>`
14    pub Superclass: String,
15    #[serde(default)]
16    /// Contains tags like `NotBrowsable` and `NotCreatable`
17    /// 
18    /// You can use `Class.is_not_browsable()` and `Class.is_not_createable()` to
19    /// get a boolean value which represents the presence of those tags.
20    pub Tags: Vec<String>,
21}
22
23impl Class {
24    /// Returns if `self.Tags` contains `"NotBrowsable"`
25    pub fn is_not_browsable(&self) -> bool {
26        self.Tags.contains(&"NotBrowsable".to_string())
27    }
28    /// Returns if `self.Tags` contains `"NotCreatable"`
29    pub fn is_not_createable(&self) -> bool {
30        self.Tags.contains(&"NotCreatable".to_string())
31    }
32}
33
34/// A function, property, or event.
35#[allow(non_snake_case)]
36#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
37pub struct ClassMember {
38    /// Common ones are `Data`, `Parts`, `Behavior`, `State`, and others.
39    /// Can be an empty string.
40    #[serde(default)]
41    pub Category: String,
42    /// Either `"Function"`, `"Property"`, or `"Event"`
43    pub MemberType: String,
44    pub Name: String,
45    /// Not parsed because it can either be a string or `SecurityInfo`
46    pub Security: serde_json::Value,
47    /// Can be empty.
48    #[serde(default)]
49    pub Serialization: Serialization,
50    pub ThreadSafety: String,
51    #[serde(default)]
52    /// Contains the type of the value, like `bool` or `number`
53    /// Can be empty.
54    pub ValueType: ValueType,
55}
56
57#[allow(non_snake_case)]
58#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
59pub struct SecurityInfo {
60    pub Read: String,
61    pub Write: String,
62}
63
64#[allow(non_snake_case)]
65#[derive(Debug, Deserialize, Clone, Default, PartialEq, Eq)]
66pub struct Serialization {
67    pub CanLoad: bool,
68    pub CanSave: bool,
69}
70
71#[allow(non_snake_case)]
72#[derive(Debug, Deserialize, Clone, Default, PartialEq, Eq)]
73pub struct ValueType {
74    /// Can be `Class`, `Primitive`, `Enum`, `DataType`, and empty.
75    pub Category: String,
76    /// Common ones are `bool`, `string`, `int`, `int64`, `Instance` and more.
77    /// Can be empty.
78    pub Name: String,
79}