Dernière activité 1715772553

Révision 6ee2734241ed9b135a625630f1e3f48babe86b57

config_opts.rs Brut
1#[derive(Debug, Clone, PartialEq)]
2#[allow(dead_code)]
3pub 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)]
15pub enum OptionType {
16 Single,
17 Multiple,
18}
19
20#[derive(Debug, Clone, PartialEq)]
21pub 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)]
33pub 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)]
57pub 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)]
80pub enum OperationType {
81 View,
82 Create,
83 Update,
84 Delete,
85}
86
87#[derive(Debug, Clone, PartialEq)]
88pub 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}
113