summaryrefslogtreecommitdiffstats
path: root/src/types/block.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-12-20 00:01:31 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-10-07 10:14:33 +0200
commit15bc0ad9c1515e8f326e01ca903c0d88bb787aee (patch)
tree17973661361745da860664e3893b99f70c1af097 /src/types/block.rs
Initial import of distrox code
Diffstat (limited to 'src/types/block.rs')
-rw-r--r--src/types/block.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/types/block.rs b/src/types/block.rs
new file mode 100644
index 0000000..75c1885
--- /dev/null
+++ b/src/types/block.rs
@@ -0,0 +1,39 @@
+use types::util::IPFSHash;
+use types::util::Version;
+
+#[derive(Serialize, Deserialize)]
+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(skip_serializing_if = "Vec::is_empty")]
+ 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
+ }
+}
+