sim_time/
config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct TimeConfig {
    pub(super) realtime: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub(super) sim_time: Option<SimTimeConfig>,
}

impl Default for TimeConfig {
    fn default() -> Self {
        Self {
            realtime: true,
            sim_time: None,
        }
    }
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SimTimeConfig {
    #[serde(default = "Utc::now")]
    pub(super) start_at: DateTime<Utc>,
    pub(super) tick_interval_ms: u64,
    #[serde_as(as = "serde_with::DurationSeconds<u64>")]
    pub(super) tick_duration_secs: std::time::Duration,
}