use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
fn default_true() -> bool {
true
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[schemars(extend("x-display-field" = "/enabled"))]
pub struct PluginConfig {
#[serde(default = "default_true")]
pub enabled: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schemars(extend("readOnly" = true))]
pub path: Option<PathBuf>,
}
impl Default for PluginConfig {
fn default() -> Self {
Self {
enabled: true,
path: None,
}
}
}
impl PluginConfig {
pub fn new_with_path(path: PathBuf) -> Self {
Self {
enabled: true,
path: Some(path),
}
}
}