use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
InvalidIso9660(&'static str),
InvalidUdf(&'static str),
NotDvdVideo(&'static str),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Io(e) => write!(f, "I/O error: {e}"),
Self::InvalidIso9660(s) => write!(f, "invalid ISO 9660 structure: {s}"),
Self::InvalidUdf(s) => write!(f, "invalid UDF structure: {s}"),
Self::NotDvdVideo(s) => write!(f, "not a DVD-Video disc: {s}"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Io(e) => Some(e),
_ => None,
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::Io(e)
}
}