summaryrefslogtreecommitdiffstats
path: root/src/types/block.rs
blob: f9631c99f7ce89d6d33ac88441d9b5de4f111f77 (plain)
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
use types::util::IPFSHash;
use types::util::Version;

#[derive(Serialize, Deserialize, Debug)]
pub struct Block {
    /// The version of the API in use
    #[serde(rename = "v")]
    version: Version,

    /// The parents of this Profile instance
    ///
    /// Multiple are required for merging.
    #[serde(rename = "parents")]
    #[serde(default)]
    parents: Vec<IPFSHash>,

    /// The content of this block, pointed to by IPFS hash.
    #[serde(rename = "content")]
    content: IPFSHash,
}

impl Block {
    pub fn new(version: Version, parents: Vec<IPFSHash>, content: IPFSHash) -> Self {
        Block { version, parents, content }
    }

    pub fn version(&self) -> &Version {
        &self.version
    }

    pub fn parents(&self) -> &Vec<IPFSHash> {
        &self.parents
    }

    pub fn content(&self) -> &IPFSHash {
        &self.content
    }
}