1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::{AuthorID, DirectoryEntry, ObjectID, SnapShotDirectory};
use serde::{Deserialize, Serialize};
use std::{
    collections::{BTreeMap, BTreeSet},
    fmt::{Display, Formatter},
    path::PathBuf,
};

pub mod differences;
pub mod directory;
pub mod initialize;

/// 快照
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapShot {
    /// 当前目录结构的 id
    pub directory: ObjectID,
    /// 快照的前驱节点, 可能没有, 或者一个, 或者多个
    pub previous: BTreeSet<ObjectID>,
    pub data: SnapShotData,
}

#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
pub struct SnapShotData {
    /// 快照类型, fix, test 或者其他
    pub kind: u32,
    /// The message added with the commit.
    pub message: String,
    /// The author ids of the commit.
    pub authors: BTreeSet<AuthorID>,
    // pub datetime: SystemTime
}

#[derive(Copy, Debug, Clone)]
pub enum SnapShotKind {
    Initialization = 0,
    Fix,
    Test,
}

impl Eq for SnapShot {}

impl PartialEq for SnapShot {
    fn eq(&self, other: &Self) -> bool {
        // 数据不加入校验
        self.directory.eq(&other.directory) && self.previous.eq(&other.previous)
    }
}