config_opts.rs
· 2.6 KiB · Rust
Eredeti
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum ColumnType {
String,
Integer,
Boolean,
User,
Channel,
Role,
Emoji,
Message,
}
#[derive(Debug, Clone, PartialEq)]
pub enum OptionType {
Single,
Multiple,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ColumnSuggestion {
Static {
suggestions: Vec<&'static str>,
},
Dynamic {
table_name: &'static str,
column_name: &'static str,
},
None,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Column {
/// The ID of the column
pub id: &'static str,
/// The friendly name of the column
pub name: &'static str,
/// The type of the column
pub column_type: ColumnType,
/// Whether or not the column is nullable
pub nullable: bool,
/// Suggestions to display
pub suggestions: ColumnSuggestion,
/// Whether or not the column is unique
pub unique: bool,
/// Whether or not the column is an array
pub array: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct OperationSpecific {
/// The corresponding command for ACL purposes
pub corresponding_command: &'static str,
/// Which column ids should be usable for this operation
///
/// E.g, create does not need to show created_at or id while view should
pub column_ids: Vec<&'static str>,
/// Any columns to set. For example, a last_updated column should be set on update
///
/// Variables:
/// - {user_id} => the user id of the user running the operation
/// - {now} => the current timestamp
///
/// Note: only applies to create, update and delete
///
/// Key should be of form `table_name.column_name` and value should be the value to set
pub columns_to_set: indexmap::IndexMap<&'static str, &'static str>,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum OperationType {
View,
Create,
Update,
Delete,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ConfigOption {
/// The ID of the option
pub id: &'static str,
/// The name of the option
pub name: &'static str,
/// The description of the option
pub description: &'static str,
/// The table name for the config option
pub table: &'static str,
/// The column name refering to the guild id of the config option
pub guild_id: &'static str,
/// The columns for this option
pub columns: Vec<Column>,
/// The type of the option
pub option_type: OptionType,
/// Operation specific data
pub operations: indexmap::IndexMap<OperationType, OperationSpecific>,
}
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 | } |
113 |