Add settings and constants

This commit is contained in:
Tobias Reisinger 2023-11-23 03:36:14 +01:00
parent e419923939
commit ee68405874
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
6 changed files with 26 additions and 8 deletions
emgauwa-controller/src

View file

@ -1,6 +1,15 @@
use config::Config;
use emgauwa_lib::constants;
use serde_derive::Deserialize;
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
#[allow(unused)]
pub struct Core {
pub host: String,
pub port: u16,
}
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
#[allow(unused)]
@ -14,8 +23,6 @@ pub struct Logging {
#[allow(unused)]
pub struct Settings {
pub database: String,
pub port: u16,
pub host: String,
pub logging: Logging,
}
@ -23,13 +30,20 @@ impl Default for Settings {
fn default() -> Self {
Settings {
database: String::from("sqlite://emgauwa-controller.sqlite"),
port: 5000,
host: String::from("127.0.0.1"),
logging: Logging::default(),
}
}
}
impl Default for Core {
fn default() -> Self {
Core {
host: String::from("127.0.0.1"),
port: constants::DEFAULT_PORT,
}
}
}
impl Default for Logging {
fn default() -> Self {
Logging {