use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct Settings {
#[allow(dead_code)]
pub host: String,
#[allow(dead_code)]
pub port: u16,
#[allow(dead_code)]
pub debug: bool,
#[serde(default = "default_resource_prefix_format")]
#[allow(dead_code)]
pub resource_prefix_format: String,
}
impl Settings {
pub fn new() -> Self {
Self {
host: "127.0.0.1".to_string(),
port: 8000,
debug: false,
resource_prefix_format: default_resource_prefix_format(),
}
}
#[allow(dead_code)]
pub fn debug(&self) -> bool {
self.debug
}
#[allow(dead_code)]
pub fn resource_prefix_format(&self) -> &str {
&self.resource_prefix_format
}
}
impl Default for Settings {
fn default() -> Self {
Self::new()
}
}
fn default_resource_prefix_format() -> String {
"resource://".to_string()
}