use std::fmt;
use std::io;
use std::num::ParseIntError;
use std::num::TryFromIntError;
use std::str::Utf8Error;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
Utf8(Utf8Error),
Parse(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Io(e) => e.fmt(f),
Self::Utf8(e) => e.fmt(f),
Self::Parse(e) => write!(f, "Invalid value encountered while parsing Wii ISO: {e}"),
}
}
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Self::Io(err)
}
}
impl From<Utf8Error> for Error {
fn from(err: Utf8Error) -> Self {
Self::Utf8(err)
}
}
impl From<ParseIntError> for Error {
fn from(_: ParseIntError) -> Self {
Self::Parse("failed to parse number".into())
}
}
impl From<TryFromIntError> for Error {
fn from(_: TryFromIntError) -> Self {
Self::Parse("failed to convert number".into())
}
}