autopulse_service/settings/
opts.rs1use autopulse_utils::Rotation;
2use serde::Deserialize;
3use std::path::PathBuf;
4
5#[doc(hidden)]
6const fn default_check_path() -> bool {
7 false
8}
9
10#[doc(hidden)]
11const fn default_max_retries() -> i32 {
12 5
13}
14
15#[doc(hidden)]
16const fn default_default_timer_wait() -> u64 {
17 60
18}
19
20#[doc(hidden)]
21const fn default_cleanup_days() -> u64 {
22 10
23}
24
25#[derive(Clone, Deserialize, Default)]
26#[serde(rename_all = "lowercase")]
27pub enum LogRotation {
28 Daily,
29 Minutely,
30 Hourly,
31 #[default]
32 Never,
33}
34
35impl From<LogRotation> for Rotation {
48 fn from(rotation: LogRotation) -> Self {
49 match rotation {
50 LogRotation::Daily => Self::DAILY,
51 LogRotation::Minutely => Self::MINUTELY,
52 LogRotation::Hourly => Self::HOURLY,
53 LogRotation::Never => Self::NEVER,
54 }
55 }
56}
57
58#[derive(Deserialize, Clone)]
59pub struct Opts {
60 #[serde(default = "default_check_path")]
62 pub check_path: bool,
63
64 #[serde(default = "default_max_retries")]
66 pub max_retries: i32,
67
68 #[serde(default = "default_default_timer_wait")]
70 pub default_timer_wait: u64,
71
72 #[serde(default = "default_cleanup_days")]
74 pub cleanup_days: u64,
75
76 pub log_file: Option<PathBuf>,
78
79 #[serde(default)]
81 pub log_file_rollover: LogRotation,
82}
83
84impl Default for Opts {
85 fn default() -> Self {
86 Self {
87 check_path: default_check_path(),
88 max_retries: default_max_retries(),
89 default_timer_wait: default_default_timer_wait(),
90 cleanup_days: default_cleanup_days(),
91 log_file: None,
92 log_file_rollover: LogRotation::default(),
93 }
94 }
95}