[WIP] config: impl Default for Settings

This commit is contained in:
Zynh Ludwig 2025-01-17 00:41:15 -08:00
parent 1d3eb86024
commit e16837712a

View file

@ -8,10 +8,11 @@
//! Realistically we could also just use field names like `cache_dir` and it should have //! Realistically we could also just use field names like `cache_dir` and it should have
//! the same effect if at some point having the substructs defined like this is annoying. //! the same effect if at some point having the substructs defined like this is annoying.
use serde::Deserialize;
use std::path::PathBuf; use std::path::PathBuf;
/// primary settings container /// primary settings container
#[derive(Debug)] #[derive(Debug, Deserialize)]
pub struct Settings { pub struct Settings {
/// main upload cache setings /// main upload cache setings
pub cache: Cache, pub cache: Cache,
@ -21,8 +22,15 @@ pub struct Settings {
pub database: Database, pub database: Database,
} }
impl Default for Settings {
fn default() -> Self {
// FIXME:
todo!()
}
}
/// main upload cache setings /// main upload cache setings
#[derive(Debug)] #[derive(Debug, Deserialize)]
pub struct Cache { pub struct Cache {
/// directory that the cached uploads are stored /// directory that the cached uploads are stored
/// ///
@ -34,8 +42,16 @@ pub struct Cache {
pub dir: PathBuf, pub dir: PathBuf,
} }
impl Default for Cache {
fn default() -> Self {
Self {
dir: PathBuf::from("/var/lib/nyazoom/cache"),
}
}
}
/// static serve settings /// static serve settings
#[derive(Debug)] #[derive(Debug, Deserialize)]
pub struct Dist { pub struct Dist {
/// directory that nyazoom serves statically. /// directory that nyazoom serves statically.
/// ///
@ -43,8 +59,16 @@ pub struct Dist {
pub dir: PathBuf, pub dir: PathBuf,
} }
impl Default for Dist {
fn default() -> Self {
Self {
dir: PathBuf::from("./dist"),
}
}
}
/// database settings /// database settings
#[derive(Debug)] #[derive(Debug, Deserialize)]
pub struct Database { pub struct Database {
/// database url used by [sqlx] to connect to the database /// database url used by [sqlx] to connect to the database
/// ///