reinhardt_conf/settings/
static_files.rs1use reinhardt_core::macros::settings;
6use serde::{Deserialize, Serialize};
7use std::path::PathBuf;
8
9#[settings(fragment = true, section = "static_files")]
13#[non_exhaustive]
14#[derive(Clone, Debug, Serialize, Deserialize)]
15pub struct StaticSettings {
16 #[serde(default = "default_static_url")]
18 pub url: String,
19 #[serde(default = "default_static_root")]
21 pub root: PathBuf,
22}
23
24fn default_static_url() -> String {
25 "/static/".to_string()
26}
27
28fn default_static_root() -> PathBuf {
29 PathBuf::from("static")
30}
31
32impl Default for StaticSettings {
33 fn default() -> Self {
34 Self {
35 url: "/static/".to_string(),
36 root: PathBuf::from("static"),
37 }
38 }
39}
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44 use crate::settings::fragment::SettingsFragment;
45 use rstest::rstest;
46
47 #[rstest]
48 fn test_static_files_section_name() {
49 let section = StaticSettings::section();
51
52 assert_eq!(section, "static_files");
54 }
55
56 #[rstest]
57 fn test_static_files_default_values() {
58 let settings = StaticSettings::default();
60
61 assert_eq!(settings.url, "/static/");
63 assert_eq!(settings.root, PathBuf::from("static"));
64 }
65}