Utoljára aktív 1715772553

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