46 lines
875 B
Rust
46 lines
875 B
Rust
use emgauwa_lib::{constants, utils};
|
|
use serde_derive::Deserialize;
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
#[serde(default)]
|
|
#[allow(unused)]
|
|
pub struct Logging {
|
|
pub level: String,
|
|
pub file: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
#[serde(default)]
|
|
#[allow(unused)]
|
|
pub struct Settings {
|
|
pub database: String,
|
|
pub port: u16,
|
|
pub host: String,
|
|
pub origins: Vec<String>,
|
|
pub logging: Logging,
|
|
}
|
|
|
|
impl Default for Settings {
|
|
fn default() -> Self {
|
|
Settings {
|
|
database: String::from("sqlite://emgauwa-core.sqlite"),
|
|
port: constants::DEFAULT_PORT,
|
|
host: String::from("127.0.0.1"),
|
|
origins: Vec::new(),
|
|
logging: Logging::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Logging {
|
|
fn default() -> Self {
|
|
Logging {
|
|
level: String::from("info"),
|
|
file: String::from("stdout"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn init() -> Settings {
|
|
utils::load_settings("core", "CORE")
|
|
}
|