Skip to main content

fresh_core/
config.rs

1//! Configuration types shared across crates
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use std::path::PathBuf;
6
7fn default_true() -> bool {
8    true
9}
10
11/// Configuration for a single plugin
12#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
13#[schemars(extend("x-display-field" = "/enabled"))]
14pub struct PluginConfig {
15    /// Whether this plugin is enabled (default: true)
16    /// When disabled, the plugin will not be loaded or executed.
17    #[serde(default = "default_true")]
18    pub enabled: bool,
19
20    /// Path to the plugin file (populated automatically when scanning)
21    /// This is filled in by the plugin system and should not be set manually.
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    #[schemars(extend("readOnly" = true))]
24    pub path: Option<PathBuf>,
25}
26
27impl Default for PluginConfig {
28    fn default() -> Self {
29        Self {
30            enabled: true,
31            path: None,
32        }
33    }
34}
35
36impl PluginConfig {
37    pub fn new_with_path(path: PathBuf) -> Self {
38        Self {
39            enabled: true,
40            path: Some(path),
41        }
42    }
43}