minion_engine/plugins/
registry.rs1use std::collections::HashMap;
2
3use super::PluginStep;
4
5pub struct PluginRegistry {
7 plugins: HashMap<String, Box<dyn PluginStep>>,
8}
9
10impl PluginRegistry {
11 pub fn new() -> Self {
12 Self {
13 plugins: HashMap::new(),
14 }
15 }
16
17 pub fn register(&mut self, plugin: Box<dyn PluginStep>) {
19 let name = plugin.name().to_string();
20 self.plugins.insert(name, plugin);
21 }
22
23 pub fn get(&self, name: &str) -> Option<&Box<dyn PluginStep>> {
25 self.plugins.get(name)
26 }
27
28 pub fn len(&self) -> usize {
30 self.plugins.len()
31 }
32
33 pub fn is_empty(&self) -> bool {
35 self.plugins.is_empty()
36 }
37}
38
39impl Default for PluginRegistry {
40 fn default() -> Self {
41 Self::new()
42 }
43}