metis_core/domain/documents/
metadata.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4/// Document metadata containing timestamps and other document properties
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct DocumentMetadata {
7    pub created_at: DateTime<Utc>,
8    pub updated_at: DateTime<Utc>,
9    pub exit_criteria_met: bool,
10    pub short_code: String,
11}
12
13impl DocumentMetadata {
14    /// Create new metadata with current timestamps and short code
15    pub fn new(short_code: String) -> Self {
16        let now = Utc::now();
17        Self {
18            created_at: now,
19            updated_at: now,
20            exit_criteria_met: false,
21            short_code,
22        }
23    }
24
25    /// Create metadata from parsed frontmatter data
26    pub fn from_frontmatter(
27        created_at: DateTime<Utc>,
28        updated_at: DateTime<Utc>,
29        exit_criteria_met: bool,
30        short_code: String,
31    ) -> Self {
32        Self {
33            created_at,
34            updated_at,
35            exit_criteria_met,
36            short_code,
37        }
38    }
39
40    /// Update the updated_at timestamp to now
41    pub fn update(&mut self) {
42        self.updated_at = Utc::now();
43    }
44
45    /// Mark exit criteria as met and update timestamp
46    pub fn mark_exit_criteria_met(&mut self) {
47        self.exit_criteria_met = true;
48        self.update();
49    }
50}
51
52// Note: No Default implementation as short_code is required