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
use libipld::cid::Cid;
pub use libipld::path::Path as IpldPath;
#[derive(Clone, Debug, PartialEq, Hash)]
pub struct DagPath<'a>(&'a Cid, IpldPath);
impl<'a> DagPath<'a> {
pub fn new<T: Into<IpldPath>>(cid: &'a Cid, path: T) -> Self {
Self(cid, path.into())
}
pub fn root(&self) -> &Cid {
self.0
}
pub fn path(&self) -> &IpldPath {
&self.1
}
}
impl<'a> From<&'a Cid> for DagPath<'a> {
fn from(cid: &'a Cid) -> Self {
Self(cid, Default::default())
}
}