use garde::Validate;
use serde::{Deserialize, Serialize};
use crate::{ConfigOrigin, file::ConfigOpenpgpSettings};
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, Validate)]
#[serde(rename_all = "lowercase")]
pub struct ConfigTechnologySettings {
#[serde(skip)]
#[garde(skip)]
pub(crate) origins: Vec<ConfigOrigin>,
#[garde(dive)]
openpgp: Option<ConfigOpenpgpSettings>,
}
impl ConfigTechnologySettings {
#[allow(dead_code)]
pub(crate) fn new(origins: Vec<ConfigOrigin>, openpgp: Option<ConfigOpenpgpSettings>) -> Self {
Self { origins, openpgp }
}
pub(crate) fn config_openpgp_settings(&self) -> Option<&ConfigOpenpgpSettings> {
self.openpgp.as_ref()
}
pub fn origins(&self) -> &[ConfigOrigin] {
&self.origins
}
}
impl Default for ConfigTechnologySettings {
fn default() -> Self {
Self {
origins: vec![ConfigOrigin::Default],
openpgp: Some(ConfigOpenpgpSettings::default()),
}
}
}