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())
}
}