update stock api

This commit is contained in:
weisd
2024-09-25 15:27:23 +08:00
parent ad4a32762d
commit 4f1e31999d
5 changed files with 49 additions and 16 deletions
+8
View File
@@ -65,6 +65,14 @@ impl Error {
pub fn downcast_mut<T: std::error::Error + 'static>(&mut self) -> Option<&mut T> {
self.inner.downcast_mut()
}
pub fn to_io_err(&self) -> Option<io::Error> {
if let Some(e) = self.downcast_ref::<io::Error>() {
Some(io::Error::new(e.kind(), e.to_string()))
} else {
None
}
}
}
impl<T: std::error::Error + Send + Sync + 'static> From<T> for Error {