feattle_core/
last_reload.rs1use chrono::{DateTime, Utc};
2use serde::Serialize;
3
4#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)]
7pub enum LastReload {
8 Never,
10 NoData { reload_date: DateTime<Utc> },
13 Data {
15 reload_date: DateTime<Utc>,
16 version: i32,
17 version_date: DateTime<Utc>,
18 },
19}
20
21impl LastReload {
22 pub fn reload_date(self) -> Option<DateTime<Utc>> {
24 match self {
25 LastReload::Never => None,
26 LastReload::NoData { reload_date, .. } | LastReload::Data { reload_date, .. } => {
27 Some(reload_date)
28 }
29 }
30 }
31
32 pub fn version(self) -> Option<i32> {
35 match self {
36 LastReload::Never => None,
37 LastReload::NoData { .. } => Some(0),
38 LastReload::Data { version, .. } => Some(version),
39 }
40 }
41
42 pub fn version_date(self) -> Option<DateTime<Utc>> {
44 match self {
45 LastReload::Never | LastReload::NoData { .. } => None,
46 LastReload::Data { version_date, .. } => Some(version_date),
47 }
48 }
49}