use crate::node::Node;
use serde::{Deserialize, Serialize};
fn is_false(value: &bool) -> bool {
!*value
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct EntryOptions {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(default)]
pub name: String,
#[serde(default, skip_serializing_if = "is_false")]
pub disabled: bool,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub inject: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub group: Vec<EntryOptions>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub config: Option<Node>,
}
impl EntryOptions {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
..Self::default()
}
}
pub fn with_id(mut self, id: impl Into<String>) -> Self {
self.id = Some(id.into());
self
}
pub fn with_config(mut self, config: Node) -> Self {
self.config = Some(config);
self
}
pub fn with_group(mut self, group: Vec<EntryOptions>) -> Self {
self.group = group;
self
}
pub fn with_disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}
}