metis_core/domain/documents/
metadata.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[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 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 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 pub fn update(&mut self) {
42 self.updated_at = Utc::now();
43 }
44
45 pub fn mark_exit_criteria_met(&mut self) {
47 self.exit_criteria_met = true;
48 self.update();
49 }
50}
51
52