1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use std::path::PathBuf;
6
7fn default_true() -> bool {
8 true
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
13#[schemars(extend("x-display-field" = "/enabled"))]
14pub struct PluginConfig {
15 #[serde(default = "default_true")]
18 pub enabled: bool,
19
20 #[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}