use std::fmt::Debug;
use std::fmt::Display;
use scroll::{IOread, SizeWith};
pub mod filetype_constants {
pub const MH_OBJECT: u32 = 0x1;
pub const MH_EXECUTE: u32 = 0x2;
pub const MH_FVMLIB: u32 = 0x3;
pub const MH_CORE: u32 = 0x4;
pub const MH_PRELOAD: u32 = 0x5;
pub const MH_DYLIB: u32 = 0x6;
pub const MH_DYLINKER: u32 = 0x7;
pub const MH_BUNDLE: u32 = 0x8;
pub const MH_DYLIB_STUB: u32 = 0x9;
pub const MH_DSYM: u32 = 0xa;
pub const MH_KEXT_BUNDLE: u32 = 0xb;
}
use self::filetype_constants::*;
#[derive(Clone, IOread, SizeWith)]
pub struct FileType(pub u32);
impl FileType {
pub fn string_value(&self) -> String {
match self.0 {
MH_OBJECT => "Object".to_string(),
MH_EXECUTE => "Exec".to_string(),
MH_FVMLIB => "FVMLib".to_string(),
MH_CORE => "Core".to_string(),
MH_PRELOAD => "Preloaded".to_string(),
MH_DYLIB => "Dylib".to_string(),
MH_DYLINKER => "Dylinker".to_string(),
MH_BUNDLE => "Bundle".to_string(),
MH_DYLIB_STUB => "Dylib stub".to_string(),
MH_DSYM => "dSYM".to_string(),
MH_KEXT_BUNDLE => "Kext bundle".to_string(),
any => any.to_string(),
}
}
}
impl Debug for FileType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.string_value())
}
}
impl Display for FileType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.string_value())
}
}