Add SpecificIoError trait support for tagged error

This commit is contained in:
Félix Saparelli 2022-01-16 19:16:07 +13:00
parent 44a44a50d1
commit 4085fc522c
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 17 additions and 0 deletions

View File

@ -13,6 +13,8 @@ use crate::{
ignore::IgnoreFilterer,
};
use super::SpecificIoError;
/// Errors occurring from reconfigs.
#[derive(Debug, Diagnostic, Error)]
#[non_exhaustive]
@ -158,3 +160,18 @@ impl From<TaggedFiltererError> for RuntimeError {
}
}
}
impl<T> SpecificIoError<Result<T, TaggedFiltererError>> for Result<T, std::io::Error> {
fn about(self, context: &'static str) -> Result<T, TaggedFiltererError> {
self.map_err(|err| err.about(context))
}
}
impl SpecificIoError<TaggedFiltererError> for std::io::Error {
fn about(self, context: &'static str) -> TaggedFiltererError {
TaggedFiltererError::IoError {
about: context,
err: self,
}
}
}