add: missing Error::source impl

This commit is contained in:
Joonas Koivunen 2020-06-09 14:46:33 +03:00
parent 4359e6666b
commit 719163c662

View File

@ -37,7 +37,17 @@ impl fmt::Display for UnixFsReadFailed {
}
}
impl std::error::Error for UnixFsReadFailed {}
impl std::error::Error for UnixFsReadFailed {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use UnixFsReadFailed::*;
match self {
InvalidDagPb(e) => Some(e),
InvalidUnixFs(e) => Some(e),
NoData => None
}
}
}
impl<'a> TryFrom<&'a merkledag::PBNode<'a>> for unixfs::Data<'a> {
type Error = UnixFsReadFailed;