Impl Display for StoreLinkConsistencyErrorCustomData

This commit is contained in:
Matthias Beyer 2017-06-06 15:52:13 +02:00
parent 13b24cb397
commit 0155fea4c1

View file

@ -605,6 +605,23 @@ pub mod store_check {
}
impl Display for StoreLinkConsistencyErrorCustomData {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
use self::StoreLinkConsistencyErrorCustomData as SLCECD;
match self {
&SLCECD::DeadLink { ref target } => {
try!(write!(fmt, "Dead Link to '{}'", target))
},
&SLCECD::OneDirectionalLink { ref source, ref target } => {
try!(write!(fmt,
"Link from '{}' to '{}' does exist, but not other way round",
source, target))
}
};
Ok(())
}
}
generate_custom_error_types!(
@ -631,6 +648,8 @@ pub mod store_check {
pub type Result<T> = RResult<T, SLCE>;
}
use self::result::Result;
pub trait StoreLinkConsistentExt {
fn check_link_consistency(&self) -> Result<()>;
}