config_opts.rs
· 2.7 KiB · Rust
Eredeti
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum ColumnType {
String {},
Integer {},
BitFlag {
/// The bit flag values
values: indexmap::IndexMap<&'static str, u64>,
},
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 | 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)] |
19 | pub enum OptionType { |
20 | Single, |
21 | Multiple, |
22 | } |
23 | |
24 | #[derive(Debug, Clone, PartialEq)] |
25 | pub 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)] |
37 | pub 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)] |
61 | pub 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)] |
84 | pub enum OperationType { |
85 | View, |
86 | Create, |
87 | Update, |
88 | Delete, |
89 | } |
90 | |
91 | #[derive(Debug, Clone, PartialEq)] |
92 | pub 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 |