mago_analyzer/plugin/
plugin.rs1use crate::plugin::PluginRegistry;
4
5#[derive(Debug, Clone)]
7pub struct PluginMeta {
8 pub id: &'static str,
10 pub name: &'static str,
12 pub description: &'static str,
14 pub aliases: &'static [&'static str],
16 pub default_enabled: bool,
18}
19
20impl PluginMeta {
21 #[must_use]
23 pub const fn new(
24 id: &'static str,
25 name: &'static str,
26 description: &'static str,
27 aliases: &'static [&'static str],
28 default_enabled: bool,
29 ) -> Self {
30 Self { id, name, description, aliases, default_enabled }
31 }
32
33 #[must_use]
35 pub fn matches(&self, name: &str) -> bool {
36 let name_lower = name.to_lowercase();
37 if self.id.to_lowercase() == name_lower {
38 return true;
39 }
40 self.aliases.iter().any(|alias| alias.to_lowercase() == name_lower)
41 }
42}
43
44pub trait Plugin: Send + Sync {
46 fn meta(&self) -> &'static PluginMeta;
48
49 fn register(&self, registry: &mut PluginRegistry);
51}