ralph/contracts/config/
plugin.rs1use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11use std::collections::BTreeMap;
12
13#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
15#[serde(default, deny_unknown_fields)]
16pub struct PluginsConfig {
17 pub plugins: BTreeMap<String, PluginConfig>,
19}
20
21impl PluginsConfig {
22 pub fn merge_from(&mut self, other: Self) {
23 for (id, patch) in other.plugins {
24 self.plugins
25 .entry(id)
26 .and_modify(|existing| existing.merge_from(patch.clone()))
27 .or_insert(patch);
28 }
29 }
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
34#[serde(default, deny_unknown_fields)]
35pub struct PluginConfig {
36 pub enabled: Option<bool>,
38
39 pub config: Option<serde_json::Value>,
41}
42
43impl PluginConfig {
44 pub fn merge_from(&mut self, other: Self) {
45 if other.enabled.is_some() {
46 self.enabled = other.enabled;
47 }
48 if other.config.is_some() {
49 self.config = other.config;
50 }
51 }
52}