sapphire_framework_sync/
entry.rs1use grain_id::GrainId;
4use serde::{Deserialize, Serialize};
5
6use crate::hash::ContentHash;
7use crate::hlc::Hlc;
8use crate::vv::{Dot, VersionVector};
9
10#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(tag = "kind", rename_all = "snake_case")]
13pub enum Content {
14 File { hash: ContentHash, len: u64 },
15 Tombstone,
16}
17
18impl Content {
19 pub fn hash(&self) -> Option<ContentHash> {
20 match self {
21 Content::File { hash, .. } => Some(*hash),
22 Content::Tombstone => None,
23 }
24 }
25
26 pub fn is_tombstone(&self) -> bool {
27 matches!(self, Content::Tombstone)
28 }
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
33pub struct Entry {
34 pub path: String,
36 pub content: Content,
37 pub hlc: Hlc,
38 pub dot: Dot,
39 pub context: VersionVector,
41 pub author: GrainId,
43}
44
45#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
47pub struct PathUpdate {
48 pub path: String,
49 pub versions: Vec<Entry>,
50 pub seen: VersionVector,
51}