changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / rust/lib/obj/src/object/meta.rs

changeset 698: 96958d3eb5b0
parent: c7165d93a9eb
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 //! # Meta types
2 use crate::Objective;
3 
4 use chrono::{DateTime, Utc};
5 use serde::{Deserialize, Serialize};
6 /// Meta object
7 ///
8 /// This struct is built into other Objects and provides contextual data
9 #[derive(Serialize, Deserialize, Debug, Hash)]
10 pub struct Meta {
11  tags: Option<String>,
12  properties: Option<Vec<Property>>,
13  timestamp: DateTime<Utc>,
14 }
15 
16 impl Meta {
17  pub fn new() -> Self {
18  Meta {
19  tags: None,
20  properties: None,
21  timestamp: Utc::now(),
22  }
23  }
24 }
25 
26 impl Default for Meta {
27  fn default() -> Self {
28  Meta::new()
29  }
30 }
31 
32 impl Objective for Meta {}
33 
34 /// Property object
35 ///
36 /// An isolated property consisting of a (key,val) pair.
37 ///
38 /// TODO <2021-08-17 Tue 01:28> - this should be a trait. make
39 /// metadata module for this.
40 #[derive(Serialize, Deserialize, Debug, Hash)]
41 pub struct Property {
42  key: String,
43  val: String,
44 }
45 
46 /// Summary object
47 ///
48 /// A summary of an object.
49 ///
50 /// TODO <2021-08-17 Tue 01:30> make this a trait too.
51 #[derive(Serialize, Deserialize, Debug, Hash)]
52 pub struct Summary {
53  meta: Meta,
54  summary: String,
55 }
56 
57 /// Note object
58 ///
59 /// A note pertaining to one or many objects.
60 #[derive(Serialize, Deserialize, Debug, Hash)]
61 pub struct Note {
62  meta: Meta,
63  content: String,
64 }