1use crate::action::Action;
2use crate::Tools;
3use crate::PLUGIN_TOOLS;
4use json::{array, object, JsonValue};
5use std::any::type_name;
6pub trait Module {
8 fn _name(&self) -> &'static str {
11 type_name::<Self>().split("::").collect::<Vec<&str>>()[3].to_lowercase().leak()
12 }
13 fn title(&self) -> &'static str;
15 fn description(&self) -> &'static str {
17 ""
18 }
19 fn icon(&self) -> &'static str {
22 ""
23 }
24 fn table(&self) -> bool {
27 false
28 }
29 fn _table_name(&self) -> &'static str {
31 let t = type_name::<Self>().split("::").collect::<Vec<&str>>();
32 format!("{}_{}", t[2], t[3]).leak()
33 }
34 fn table_key(&mut self) -> &'static str {
36 "id"
37 }
38 fn table_unique(&self) -> &'static [&'static str] {
40 &[]
41 }
42 fn table_index(&mut self) -> &'static [&'static [&'static str]] {
44 &[]
45 }
46 fn table_partition(&mut self) -> bool {
48 false
49 }
50 fn table_partition_columns(&mut self) -> JsonValue {
56 array![]
57 }
58 fn action(&mut self, name: &str) -> Result<Box<dyn Action>, String>;
62 fn fields(&mut self) -> JsonValue {
64 object! {}
65 }
66 fn tools(&mut self) -> Tools {
68 let tools = PLUGIN_TOOLS.lock().unwrap();
69 let tools = tools.get("tools").unwrap().clone();
70 tools
71 }
72}