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