use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
NotMachO,
Structural(String),
NoMatchingArchSlice,
Other(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotMachO => f.write_str("input is not a Mach-O binary"),
Self::Structural(s) => write!(f, "structural decode error: {s}"),
Self::NoMatchingArchSlice => {
f.write_str("no matching architecture slice in fat binary")
}
Self::Other(s) => f.write_str(s),
}
}
}
impl std::error::Error for Error {}
impl From<goblin::error::Error> for Error {
fn from(e: goblin::error::Error) -> Self {
Self::Structural(e.to_string())
}
}