Última actividad 1715772553

rootspring's Avatar rootspring revisó este gist 1715772553. Ir a la revisión

Sin cambios

rootspring's Avatar rootspring revisó este gist 1715771634. Ir a la revisión

1 file changed, 13 insertions, 8 deletions

config_opts.rs

@@ -1,14 +1,18 @@
1 1 #[derive(Debug, Clone, PartialEq)]
2 2 #[allow(dead_code)]
3 3 pub enum ColumnType {
4 - String,
5 - Integer,
6 - Boolean,
7 - User,
8 - Channel,
9 - Role,
10 - Emoji,
11 - Message,
4 + String {},
5 + Integer {},
6 + BitFlag {
7 + /// The bit flag values
8 + values: indexmap::IndexMap<&'static str, u64>,
9 + },
10 + Boolean {},
11 + User {},
12 + Channel {},
13 + Role {},
14 + Emoji {},
15 + Message {},
12 16 }
13 17
14 18 #[derive(Debug, Clone, PartialEq)]
@@ -110,3 +114,4 @@ pub struct ConfigOption {
110 114 /// Operation specific data
111 115 pub operations: indexmap::IndexMap<OperationType, OperationSpecific>,
112 116 }
117 +

rootspring's Avatar rootspring revisó este gist 1715771300. Ir a la revisión

1 file changed, 112 insertions

config_opts.rs(archivo creado)

@@ -0,0 +1,112 @@
1 + #[derive(Debug, Clone, PartialEq)]
2 + #[allow(dead_code)]
3 + pub enum ColumnType {
4 + String,
5 + Integer,
6 + Boolean,
7 + User,
8 + Channel,
9 + Role,
10 + Emoji,
11 + Message,
12 + }
13 +
14 + #[derive(Debug, Clone, PartialEq)]
15 + pub enum OptionType {
16 + Single,
17 + Multiple,
18 + }
19 +
20 + #[derive(Debug, Clone, PartialEq)]
21 + pub enum ColumnSuggestion {
22 + Static {
23 + suggestions: Vec<&'static str>,
24 + },
25 + Dynamic {
26 + table_name: &'static str,
27 + column_name: &'static str,
28 + },
29 + None,
30 + }
31 +
32 + #[derive(Debug, Clone, PartialEq)]
33 + pub struct Column {
34 + /// The ID of the column
35 + pub id: &'static str,
36 +
37 + /// The friendly name of the column
38 + pub name: &'static str,
39 +
40 + /// The type of the column
41 + pub column_type: ColumnType,
42 +
43 + /// Whether or not the column is nullable
44 + pub nullable: bool,
45 +
46 + /// Suggestions to display
47 + pub suggestions: ColumnSuggestion,
48 +
49 + /// Whether or not the column is unique
50 + pub unique: bool,
51 +
52 + /// Whether or not the column is an array
53 + pub array: bool,
54 + }
55 +
56 + #[derive(Debug, Clone, PartialEq)]
57 + pub struct OperationSpecific {
58 + /// The corresponding command for ACL purposes
59 + pub corresponding_command: &'static str,
60 +
61 + /// Which column ids should be usable for this operation
62 + ///
63 + /// E.g, create does not need to show created_at or id while view should
64 + pub column_ids: Vec<&'static str>,
65 +
66 + /// Any columns to set. For example, a last_updated column should be set on update
67 + ///
68 + /// Variables:
69 + /// - {user_id} => the user id of the user running the operation
70 + /// - {now} => the current timestamp
71 + ///
72 + /// Note: only applies to create, update and delete
73 + ///
74 + /// Key should be of form `table_name.column_name` and value should be the value to set
75 + pub columns_to_set: indexmap::IndexMap<&'static str, &'static str>,
76 + }
77 +
78 + #[derive(Debug, Clone, PartialEq)]
79 + #[allow(dead_code)]
80 + pub enum OperationType {
81 + View,
82 + Create,
83 + Update,
84 + Delete,
85 + }
86 +
87 + #[derive(Debug, Clone, PartialEq)]
88 + pub struct ConfigOption {
89 + /// The ID of the option
90 + pub id: &'static str,
91 +
92 + /// The name of the option
93 + pub name: &'static str,
94 +
95 + /// The description of the option
96 + pub description: &'static str,
97 +
98 + /// The table name for the config option
99 + pub table: &'static str,
100 +
101 + /// The column name refering to the guild id of the config option
102 + pub guild_id: &'static str,
103 +
104 + /// The columns for this option
105 + pub columns: Vec<Column>,
106 +
107 + /// The type of the option
108 + pub option_type: OptionType,
109 +
110 + /// Operation specific data
111 + pub operations: indexmap::IndexMap<OperationType, OperationSpecific>,
112 + }
Siguiente Anterior