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
//! Create and compare commits in an underlying merkle tree.
use serde::{Deserialize, Serialize};

mod integrity;
mod proof;
mod tree;

pub use integrity::{event_log_commit_tree_file, vault_commit_tree_file};

pub use proof::{
    CommitHash, CommitPair, CommitProof, CommitRelationship, Comparison,
};
pub use tree::{CommitTree, MultiTree};

/// Enumerates the kind set after synchronization was attempted.
#[derive(Serialize, Deserialize)]
pub enum SyncKind {
    /// Local and remote are equal.
    Equal,
    /// Safe synchronization was made.
    Safe,
    /// Forced synchronization was performed.
    Force,
    /// Synchronization is not safe and a
    /// forceful attempt is required.
    Unsafe,
}

/// Information yielded after attempting synchronization.
#[derive(Serialize, Deserialize)]
pub struct SyncInfo {
    /// Local and remote proofs before synchronization.
    pub before: (CommitProof, CommitProof),
    /// Proof after synchronization.
    ///
    /// If the root hashes for local and remote are up to
    /// date this will be `None`.
    pub after: Option<CommitProof>,

    /// The status of the synchronization attempt.
    pub status: SyncKind,
}