use crate::action::Action;
use crate::Tools;
use crate::PLUGIN_TOOLS;
use json::{array, object, JsonValue};
use std::any::type_name;
pub trait Module {
fn _name(&self) -> &'static str {
type_name::<Self>().split("::").collect::<Vec<&str>>()[3].to_lowercase().leak()
}
fn title(&self) -> &'static str;
fn description(&self) -> &'static str {
""
}
fn icon(&self) -> &'static str {
""
}
fn table(&self) -> bool {
false
}
fn _table_name(&self) -> &'static str {
let t = type_name::<Self>().split("::").collect::<Vec<&str>>();
format!("{}_{}", t[2], t[3]).leak()
}
fn table_key(&mut self) -> &'static str {
"id"
}
fn table_unique(&self) -> &'static [&'static str] {
&[]
}
fn table_index(&mut self) -> &'static [&'static [&'static str]] {
&[]
}
fn table_partition(&mut self) -> bool {
false
}
fn table_partition_columns(&mut self) -> JsonValue {
array![]
}
fn action(&mut self, name: &str) -> Result<Box<dyn Action>, String>;
fn fields(&mut self) -> JsonValue {
object! {}
}
fn tools(&mut self) -> Tools {
let tools = PLUGIN_TOOLS.lock().unwrap();
let tools = tools.get("tools").unwrap().clone();
tools
}
}