use serde::Deserialize;
use std::path::{Path, PathBuf};
use crate::error::Error;
#[allow(clippy::module_name_repetitions)]
#[derive(Debug, Deserialize, Clone)]
pub struct Security {
#[serde(default = "Security::default_allow_anonymous")]
allow_anonymous: bool,
#[serde(default = "Security::default_password_file")]
password_file: Option<PathBuf>,
}
impl Security {
#[must_use]
pub const fn default_allow_anonymous() -> bool {
true
}
#[must_use]
pub const fn default_password_file() -> Option<PathBuf> {
None
}
#[must_use]
pub const fn allow_anonymous(&self) -> bool {
self.allow_anonymous
}
#[must_use]
pub fn password_file(&self) -> Option<&Path> {
self.password_file.as_deref()
}
pub const fn validate(&self) -> Result<(), Error> {
Ok(())
}
}
impl Default for Security {
fn default() -> Self {
Self {
allow_anonymous: Self::default_allow_anonymous(),
password_file: Self::default_password_file(),
}
}
}