mirror of
https://github.com/Theaninova/mhlib.git
synced 2026-01-06 00:32:53 +00:00
Split project
This commit is contained in:
34
rust/springylib/src/archive/error.rs
Normal file
34
rust/springylib/src/archive/error.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
BinRw(binrw::Error),
|
||||
Io(std::io::Error),
|
||||
Unsupported { reason: String },
|
||||
}
|
||||
|
||||
impl From<binrw::Error> for Error {
|
||||
fn from(value: binrw::Error) -> Self {
|
||||
Error::BinRw(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(value: std::io::Error) -> Self {
|
||||
Error::Io(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::BinRw(e) => write!(f, "{}", e),
|
||||
Error::Io(e) => write!(f, "{}", e),
|
||||
Error::Unsupported { reason } => write!(f, "Unsupported Archive: {}", reason),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user