ipld_block_builder/
path.rs1use libipld::cid::Cid;
2pub use libipld::path::Path as IpldPath;
3
4#[derive(Clone, Debug, PartialEq, Hash)]
6pub struct DagPath<'a>(&'a Cid, IpldPath);
7
8impl<'a> DagPath<'a> {
9 pub fn new<T: Into<IpldPath>>(cid: &'a Cid, path: T) -> Self {
11 Self(cid, path.into())
12 }
13
14 pub fn root(&self) -> &Cid {
16 self.0
17 }
18
19 pub fn path(&self) -> &IpldPath {
21 &self.1
22 }
23}
24
25impl<'a> From<&'a Cid> for DagPath<'a> {
26 fn from(cid: &'a Cid) -> Self {
27 Self(cid, Default::default())
28 }
29}