#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use crate::prelude::*;
use core::fmt;
pub mod coff;
pub mod relocation;
pub mod optional;
pub mod section;
pub mod pe;
mod prelude;
#[derive(Debug)]
pub enum Error {
OffsetOutOfRange,
BadOptionalHeader,
BadString(alloc::string::FromUtf8Error),
MissingPeHeader,
MissingCoffHeader,
MissingMagicNumber,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::OffsetOutOfRange => f.write_str("Offset out of range!"),
Error::BadOptionalHeader => f.write_str("Failed to parse optional header!"),
Error::BadString(e) => f.write_fmt(format_args!("Failed to parse string: {}!", e)),
Error::MissingPeHeader => f.write_str("Missing PE header!"),
Error::MissingCoffHeader => f.write_str("Missing COFF header!"),
Error::MissingMagicNumber => f.write_str("Missing magic number!"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}