mindcontrol_types/
collection.rs

1use litty::literal;
2use serde::{Deserialize, Serialize};
3
4/// Collection base type.
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct CollectionBase {
7    /// Schema version.
8    pub v: CollectionBaseV1,
9    /// Unix timestamp in milliseconds when the collection version was updated.
10    pub time: i64,
11    /// Major collection version number.
12    pub major: u16,
13    /// Minor collection version number.
14    pub minor: u16,
15    /// Signifies if the collection version is a draft.
16    pub draft: bool,
17}
18
19#[literal(1)]
20pub struct CollectionBaseV1;
21
22/// Collection version.
23#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
24pub struct CollectionV1 {
25    /// Schema version.
26    pub v: CollectionBaseV1,
27    /// Unix timestamp in milliseconds when the collection version was updated.
28    pub time: i64,
29    /// Major collection version number.
30    pub major: u16,
31    /// Minor collection version number.
32    pub minor: u16,
33    /// Signifies if the collection version is a draft.
34    pub draft: bool,
35    /// Collection payload JSON.
36    pub payload: String,
37    /// Collection settings JSON.
38    pub settings: Option<String>,
39}
40
41/// Parsed collection version. Unlike regular collection, the payload property is a parsed JSON object.
42#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
43pub struct CollectionParsedV1 {
44    /// Schema version.
45    pub v: CollectionBaseV1,
46    /// Unix timestamp in milliseconds when the collection version was updated.
47    pub time: i64,
48    /// Major collection version number.
49    pub major: u16,
50    /// Minor collection version number.
51    pub minor: u16,
52    /// Signifies if the collection version is a draft.
53    pub draft: bool,
54    /// Collection payload.
55    pub payload: super::payload::PayloadV1,
56    /// Collection settings.
57    pub settings: CollectionSettings,
58}
59
60/// Collection settings object. Unused for now.
61#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum CollectionSettings {
64    CollectionSettingsObj(CollectionSettingsObj),
65    Null(()),
66}
67
68#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
69pub struct CollectionSettingsObj {}