diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..42dda81 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,19 @@ +use serde::{ + Deserialize, + Serialize, +}; +use std::path::PathBuf; + +#[derive(Debug, Serialize, Deserialize)] +#[serde(default, rename_all = "kebab-case")] +pub struct Config { + pub database_path: PathBuf, +} + +impl Default for Config { + fn default() -> Self { + Config { + database_path: crate::DEFAULT_DATABASE_PATH.into(), + } + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ace0340..0dc1e9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,10 +4,6 @@ use std::{ boxed::Box, error::Error, }; -use serde::{ - Deserialize, - Serialize, -}; use sqlx::{ prelude::*, sqlite::{ @@ -21,26 +17,16 @@ use tokio::{ fs::File, io::AsyncReadExt, }; -use crate::cli::Options; +use crate::{ + cli::Options, + config::Config, +}; mod cli; +mod config; const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; -#[derive(Debug, Serialize, Deserialize)] -#[serde(default, rename_all = "kebab-case")] -struct Config { - database_path: PathBuf, -} - -impl Default for Config { - fn default() -> Self { - Config { - database_path: DEFAULT_DATABASE_PATH.into(), - } - } -} - #[tokio::main] async fn main() -> Result<(), Box> { let clap_matches = Options::clap().get_matches();