reinhardt_conf/settings/
cache.rs1use reinhardt_core::macros::settings;
6use serde::{Deserialize, Serialize};
7
8fn default_backend() -> String {
9 "memory".to_string()
10}
11
12fn default_timeout() -> u64 {
13 300
14}
15
16#[settings(fragment = true, section = "cache")]
20#[non_exhaustive]
21#[derive(Clone, Debug, Serialize, Deserialize)]
22pub struct CacheSettings {
23 #[serde(default = "default_backend")]
25 pub backend: String,
26 pub location: Option<String>,
28 #[serde(default = "default_timeout")]
30 pub timeout: u64,
31}
32
33impl Default for CacheSettings {
34 fn default() -> Self {
35 Self {
36 backend: "memory".to_string(),
37 location: None,
38 timeout: 300,
39 }
40 }
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46 use crate::settings::fragment::SettingsFragment;
47 use rstest::rstest;
48
49 #[rstest]
50 fn test_cache_section_name() {
51 let section = CacheSettings::section();
53
54 assert_eq!(section, "cache");
56 }
57
58 #[rstest]
59 fn test_cache_default_values() {
60 let settings = CacheSettings::default();
62
63 assert_eq!(settings.backend, "memory");
65 assert!(settings.location.is_none());
66 assert_eq!(settings.timeout, 300);
67 }
68}