summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-11-28 10:45:56 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-11-28 10:46:45 +0100
commitbfb222f401ad39f1a49281ac1c2a4420326ae12e (patch)
treef3e2648b66b72c8f55d61f1e12b5697defd9d3fd /src
parent250413999574040a2fdaa29e1906b7a5a2bd0470 (diff)
Make node parents recognizable in IPLD
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/types/node.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/types/node.rs b/src/types/node.rs
index f9077f5..aead32c 100644
--- a/src/types/node.rs
+++ b/src/types/node.rs
@@ -6,8 +6,7 @@ pub struct Node {
version: String,
/// Parent Nodes, identified by cid
- #[getset(get = "pub")]
- parents: Vec<crate::cid::Cid>,
+ parents: Vec<crate::types::encodable_cid::EncodableCid>,
/// The actual payload of the node, which is stored in another document identified by this cid
payload: crate::types::encodable_cid::EncodableCid,
@@ -17,13 +16,25 @@ impl daglib::Node for Node {
type Id = crate::cid::Cid;
fn parent_ids(&self) -> Vec<Self::Id> {
- self.parents.clone()
+ self.parents()
}
}
impl Node {
pub fn new(version: String, parents: Vec<crate::cid::Cid>, payload: crate::cid::Cid) -> Self {
- Self { version, parents, payload: payload.into() }
+ Self {
+ version,
+ parents: parents.into_iter().map(crate::types::encodable_cid::EncodableCid::from).collect(),
+ payload: payload.into()
+ }
+ }
+
+ pub fn parents(&self) -> Vec<crate::cid::Cid> {
+ self.parents
+ .clone()
+ .into_iter()
+ .map(crate::types::encodable_cid::EncodableCid::into)
+ .collect()
}
pub fn payload(&self) -> crate::cid::Cid {