use enum_iterator::Sequence;
use num_enum::{IntoPrimitive, TryFromPrimitive};
use std::fmt;
use std::str::FromStr;
use crate::core::errors::ConversionError;
use crate::core::errors::ParserError;
#[derive(
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Sequence, IntoPrimitive, TryFromPrimitive,
)]
#[repr(u8)]
#[non_exhaustive]
pub enum Code {
EmptyPartition = 0x00,
FAT12 = 0x01,
XenixRoot = 0x02,
XenixUser = 0x03,
FAT16 = 0x04,
ExtendedPartition = 0x05,
FAT16B = 0x06,
HPFSNTFSExfat = 0x07,
AIX = 0x08,
AIXBootable = 0x09,
OS2BootManager = 0x0a,
W95FAT32 = 0x0b,
W95FAT32LBA = 0x0c,
W95FAT16LBA = 0x0e,
W95ExtendedLBA = 0x0f,
OPUS = 0x10,
HiddenFAT12 = 0x11,
CompaqDiagnostics = 0x12,
HiddenFAT16 = 0x14,
HiddenFAT16B = 0x16,
HiddenHPFSNTFSExFat = 0x17,
ASTSmartSleep = 0x18,
HiddenW95FAT32 = 0x1b,
HiddenW95FAT32LBA = 0x1c,
HiddenW95FAT16LBA = 0x1e,
NecDOS = 0x24,
HiddenNTFSRescue = 0x27,
Plan9 = 0x39,
PartitionMagic = 0x3c,
Venix80286 = 0x40,
PPCPrepBoot = 0x41,
Sfs = 0x42,
QNX4Primary = 0x4d,
QNX4Secondary = 0x4e,
QNX4Tertiary = 0x4f,
OnTrackDM = 0x50,
OnTrackDM6Aux1 = 0x51,
CPM80 = 0x52,
OnTrackDM6Aux3 = 0x53,
OnTrackDM6Ddo = 0x54,
EZDrive = 0x55,
GoldenBow = 0x56,
PriamEDisk = 0x5c,
SpeedStor = 0x61,
GNUHurdSystemV = 0x63,
NovellNetware286 = 0x64,
NovellNetware386 = 0x65,
DiskSecureMultiBoot = 0x70,
PCIX = 0x75,
OldMinix = 0x80,
MinixOldLinux = 0x81,
LinuxSwap = 0x82,
Linux = 0x83,
OS2HiddenCDrive = 0x84,
LinuxExtended = 0x85,
FAT16VolumeSet = 0x86,
NTFSVolumeSet = 0x87,
LinuxPlaintext = 0x88,
LinuxLVM = 0x8e,
Amoeba = 0x93,
AmoebaBadBlockTable = 0x94,
BSDOs = 0x9f,
IBMThinkpad = 0xa0,
FreeBSD = 0xa5,
OpenBSD = 0xa6,
NextStep = 0xa7,
DarwinUFS = 0xa8,
NetBSD = 0xa9,
DarwinBoot = 0xab,
HFSHFSPlus = 0xaf,
BSDIFs = 0xb7,
BSDISwap = 0xb8,
BootWizardHidden = 0xbb,
AcronisFAT32LBA = 0xbc,
SolarisBoot = 0xbe,
Solaris = 0xbf,
DRDOSSecuredFAT12 = 0xc1,
DRDOSSecuredFAT16 = 0xc4,
DRDOSSecuredFAT16B = 0xc6,
Syrinx = 0xc7,
NonFsData = 0xda,
CPMCtOs = 0xdb,
DellUtilityFAT16 = 0xde,
BootIt = 0xdf,
DOSAccess = 0xe1,
DOSRO = 0xe3,
SpeedStorFAT16 = 0xe4,
FreedesktopBoot = 0xea,
BeOSBFS = 0xeb,
GPTProtectiveMBR = 0xee,
EfiSystem = 0xef,
PARISCLinux = 0xf0,
SDSpeedstor = 0xf1,
SpeedStorFAT16B = 0xf4,
DOSSecondary = 0xf2,
EBBRProtective = 0xf8,
VMWareVMFS = 0xfb,
VMWareVMKCORE = 0xfc,
LinuxRaidAuto = 0xfd,
LanStep = 0xfe,
XenixBadBlockTable = 0xff,
}
impl Code {
pub fn as_str(&self) -> &str {
match self {
Self::EmptyPartition => "0x00",
Self::FAT12 => "0x01",
Self::XenixRoot => "0x02",
Self::XenixUser => "0x03",
Self::FAT16 => "0x04",
Self::ExtendedPartition => "0x05",
Self::FAT16B => "0x06",
Self::HPFSNTFSExfat => "0x07",
Self::AIX => "0x08",
Self::AIXBootable => "0x09",
Self::OS2BootManager => "0x0a",
Self::W95FAT32 => "0x0b",
Self::W95FAT32LBA => "0x0c",
Self::W95FAT16LBA => "0x0e",
Self::W95ExtendedLBA => "0x0f",
Self::OPUS => "0x10",
Self::HiddenFAT12 => "0x11",
Self::CompaqDiagnostics => "0x12",
Self::HiddenFAT16 => "0x14",
Self::HiddenFAT16B => "0x16",
Self::HiddenHPFSNTFSExFat => "0x17",
Self::ASTSmartSleep => "0x18",
Self::HiddenW95FAT32 => "0x1b",
Self::HiddenW95FAT32LBA => "0x1c",
Self::HiddenW95FAT16LBA => "0x1e",
Self::NecDOS => "0x24",
Self::HiddenNTFSRescue => "0x27",
Self::Plan9 => "0x39",
Self::PartitionMagic => "0x3c",
Self::Venix80286 => "0x40",
Self::PPCPrepBoot => "0x41",
Self::Sfs => "0x42",
Self::QNX4Primary => "0x4d",
Self::QNX4Secondary => "0x4e",
Self::QNX4Tertiary => "0x4f",
Self::OnTrackDM => "0x50",
Self::OnTrackDM6Aux1 => "0x51",
Self::CPM80 => "0x52",
Self::OnTrackDM6Aux3 => "0x53",
Self::OnTrackDM6Ddo => "0x54",
Self::EZDrive => "0x55",
Self::GoldenBow => "0x56",
Self::PriamEDisk => "0x5c",
Self::SpeedStor => "0x61",
Self::GNUHurdSystemV => "0x63",
Self::NovellNetware286 => "0x64",
Self::NovellNetware386 => "0x65",
Self::DiskSecureMultiBoot => "0x70",
Self::PCIX => "0x75",
Self::OldMinix => "0x80",
Self::MinixOldLinux => "0x81",
Self::LinuxSwap => "0x82",
Self::Linux => "0x83",
Self::OS2HiddenCDrive => "0x84",
Self::LinuxExtended => "0x85",
Self::FAT16VolumeSet => "0x86",
Self::NTFSVolumeSet => "0x87",
Self::LinuxPlaintext => "0x88",
Self::LinuxLVM => "0x8e",
Self::Amoeba => "0x93",
Self::AmoebaBadBlockTable => "0x94",
Self::BSDOs => "0x9f",
Self::IBMThinkpad => "0xa0",
Self::FreeBSD => "0xa5",
Self::OpenBSD => "0xa6",
Self::NextStep => "0xa7",
Self::DarwinUFS => "0xa8",
Self::NetBSD => "0xa9",
Self::DarwinBoot => "0xab",
Self::HFSHFSPlus => "0xaf",
Self::BSDIFs => "0xb7",
Self::BSDISwap => "0xb8",
Self::BootWizardHidden => "0xbb",
Self::AcronisFAT32LBA => "0xbc",
Self::SolarisBoot => "0xbe",
Self::Solaris => "0xbf",
Self::DRDOSSecuredFAT12 => "0xc1",
Self::DRDOSSecuredFAT16 => "0xc4",
Self::DRDOSSecuredFAT16B => "0xc6",
Self::Syrinx => "0xc7",
Self::NonFsData => "0xda",
Self::CPMCtOs => "0xdb",
Self::DellUtilityFAT16 => "0xde",
Self::BootIt => "0xdf",
Self::DOSAccess => "0xe1",
Self::DOSRO => "0xe3",
Self::SpeedStorFAT16 => "0xe4",
Self::FreedesktopBoot => "0xea",
Self::BeOSBFS => "0xeb",
Self::GPTProtectiveMBR => "0xee",
Self::EfiSystem => "0xef",
Self::PARISCLinux => "0xf0",
Self::SDSpeedstor => "0xf1",
Self::SpeedStorFAT16B => "0xf4",
Self::DOSSecondary => "0xf2",
Self::EBBRProtective => "0xf8",
Self::VMWareVMFS => "0xfb",
Self::VMWareVMKCORE => "0xfc",
Self::LinuxRaidAuto => "0xfd",
Self::LanStep => "0xfe",
Self::XenixBadBlockTable => "0xff",
}
}
pub fn to_u32(&self) -> u32 {
*self as u8 as u32
}
}
impl AsRef<Code> for Code {
#[inline]
fn as_ref(&self) -> &Code {
self
}
}
impl AsRef<str> for Code {
#[inline]
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl fmt::Display for Code {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl TryFrom<&[u8]> for Code {
type Error = ConversionError;
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
std::str::from_utf8(bytes)
.map_err(|e| {
ConversionError::Code(format!(
"bytes to UTF-8 string slice conversion error. {:?}",
e
))
})
.and_then(|s| Self::from_str(s).map_err(|e| ConversionError::Code(e.to_string())))
}
}
impl TryFrom<Vec<u8>> for Code {
type Error = ConversionError;
#[inline]
fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
Self::try_from(bytes.as_slice())
}
}
impl FromStr for Code {
type Err = ParserError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let err_missing_dquote = format!("missing closing double-quote in: {}", s);
let err_missing_quote = format!("missing closing quote in: {}", s);
let trimmed = s.trim();
let stripped = if trimmed.starts_with('"') {
trimmed
.strip_prefix('"')
.and_then(|s| s.strip_suffix('"'))
.ok_or(ParserError::Code(err_missing_dquote))
} else if trimmed.starts_with('\'') {
trimmed
.strip_prefix('\'')
.and_then(|s| s.strip_suffix('\''))
.ok_or(ParserError::Code(err_missing_quote))
} else {
Ok(trimmed)
}?;
stripped
.trim()
.strip_prefix("0x")
.ok_or(ParserError::Code(format!("missing '0x' prefix in: {}", s)))
.and_then(|h| {
u8::from_str_radix(h, 16).map_err(|e| {
let err_msg = format!("invalid hexadecimal string: {} {:?}", s, e);
ParserError::Code(err_msg)
})
})
.and_then(|n| {
Self::try_from(n).map_err(|_| {
let err_msg = format!("unsupported OS type: {}", s);
ParserError::Code(err_msg)
})
})
}
}
#[cfg(test)]
#[allow(unused_imports)]
mod tests {
use super::*;
use pretty_assertions::{assert_eq, assert_ne};
#[test]
#[should_panic(expected = "missing closing double-quote")]
fn code_can_not_parse_a_code_string_with_an_unclosed_double_quote() {
let _: Code = r#""0x82"#.parse().unwrap();
}
#[test]
#[should_panic(expected = "missing closing quote")]
fn code_can_not_parse_a_code_string_with_an_unclosed_quote() {
let _: Code = "'0x82".parse().unwrap();
}
#[test]
#[should_panic(expected = "missing '0x' prefix")]
fn code_can_not_parse_an_empty_string() {
let _: Code = "".parse().unwrap();
}
#[test]
#[should_panic(expected = "missing '0x' prefix")]
fn code_can_not_parse_a_code_missing_its_0x_prefix() {
let _: Code = "82".parse().unwrap();
}
#[test]
#[should_panic(expected = "invalid hexadecimal string")]
fn code_can_not_parse_a_code_string_with_an_invalid_hexadecimal() {
let _: Code = "0xDUMMY".parse().unwrap();
}
#[test]
#[should_panic(expected = "invalid hexadecimal string")]
fn code_can_not_parse_a_code_string_with_a_too_large_hexadecimal() {
let _: Code = "0xffffff".parse().unwrap();
}
#[test]
#[should_panic(expected = "bytes to UTF-8 string slice conversion error")]
fn code_can_not_convert_invalid_bytes_into_a_code() {
let bytes: Vec<u8> = vec![0, 159, 146, 150];
let _ = Code::try_from(bytes).unwrap();
}
#[test]
fn code_can_convert_valid_bytes_into_a_code() -> crate::Result<()> {
let bytes: Vec<u8> = b"0x83".to_vec();
let actual = Code::try_from(bytes)?;
let expected = Code::Linux;
assert_eq!(actual, expected);
Ok(())
}
#[test]
fn code_can_parse_a_valid_device_code() -> crate::Result<()> {
let code_str = "0x00";
let actual: Code = code_str.parse()?;
let expected = Code::EmptyPartition;
assert_eq!(actual, expected);
let code_str = "0x01";
let actual: Code = code_str.parse()?;
let expected = Code::FAT12;
assert_eq!(actual, expected);
let code_str = "0x02";
let actual: Code = code_str.parse()?;
let expected = Code::XenixRoot;
assert_eq!(actual, expected);
let code_str = "0x03";
let actual: Code = code_str.parse()?;
let expected = Code::XenixUser;
assert_eq!(actual, expected);
let code_str = "0x04";
let actual: Code = code_str.parse()?;
let expected = Code::FAT16;
assert_eq!(actual, expected);
let code_str = "0x05";
let actual: Code = code_str.parse()?;
let expected = Code::ExtendedPartition;
assert_eq!(actual, expected);
let code_str = "0x06";
let actual: Code = code_str.parse()?;
let expected = Code::FAT16B;
assert_eq!(actual, expected);
let code_str = "0x07";
let actual: Code = code_str.parse()?;
let expected = Code::HPFSNTFSExfat;
assert_eq!(actual, expected);
let code_str = "0x08";
let actual: Code = code_str.parse()?;
let expected = Code::AIX;
assert_eq!(actual, expected);
let code_str = "0x09";
let actual: Code = code_str.parse()?;
let expected = Code::AIXBootable;
assert_eq!(actual, expected);
let code_str = "0x0a";
let actual: Code = code_str.parse()?;
let expected = Code::OS2BootManager;
assert_eq!(actual, expected);
let code_str = "0x0b";
let actual: Code = code_str.parse()?;
let expected = Code::W95FAT32;
assert_eq!(actual, expected);
let code_str = "0x0c";
let actual: Code = code_str.parse()?;
let expected = Code::W95FAT32LBA;
assert_eq!(actual, expected);
let code_str = "0x0e";
let actual: Code = code_str.parse()?;
let expected = Code::W95FAT16LBA;
assert_eq!(actual, expected);
let code_str = "0x0f";
let actual: Code = code_str.parse()?;
let expected = Code::W95ExtendedLBA;
assert_eq!(actual, expected);
let code_str = "0x10";
let actual: Code = code_str.parse()?;
let expected = Code::OPUS;
assert_eq!(actual, expected);
let code_str = "0x11";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenFAT12;
assert_eq!(actual, expected);
let code_str = "0x12";
let actual: Code = code_str.parse()?;
let expected = Code::CompaqDiagnostics;
assert_eq!(actual, expected);
let code_str = "0x14";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenFAT16;
assert_eq!(actual, expected);
let code_str = "0x16";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenFAT16B;
assert_eq!(actual, expected);
let code_str = "0x17";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenHPFSNTFSExFat;
assert_eq!(actual, expected);
let code_str = "0x18";
let actual: Code = code_str.parse()?;
let expected = Code::ASTSmartSleep;
assert_eq!(actual, expected);
let code_str = "0x1b";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenW95FAT32;
assert_eq!(actual, expected);
let code_str = "0x1c";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenW95FAT32LBA;
assert_eq!(actual, expected);
let code_str = "0x1e";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenW95FAT16LBA;
assert_eq!(actual, expected);
let code_str = "0x24";
let actual: Code = code_str.parse()?;
let expected = Code::NecDOS;
assert_eq!(actual, expected);
let code_str = "0x27";
let actual: Code = code_str.parse()?;
let expected = Code::HiddenNTFSRescue;
assert_eq!(actual, expected);
let code_str = "0x39";
let actual: Code = code_str.parse()?;
let expected = Code::Plan9;
assert_eq!(actual, expected);
let code_str = "0x3c";
let actual: Code = code_str.parse()?;
let expected = Code::PartitionMagic;
assert_eq!(actual, expected);
let code_str = "0x40";
let actual: Code = code_str.parse()?;
let expected = Code::Venix80286;
assert_eq!(actual, expected);
let code_str = "0x41";
let actual: Code = code_str.parse()?;
let expected = Code::PPCPrepBoot;
assert_eq!(actual, expected);
let code_str = "0x42";
let actual: Code = code_str.parse()?;
let expected = Code::Sfs;
assert_eq!(actual, expected);
let code_str = "0x4d";
let actual: Code = code_str.parse()?;
let expected = Code::QNX4Primary;
assert_eq!(actual, expected);
let code_str = "0x4e";
let actual: Code = code_str.parse()?;
let expected = Code::QNX4Secondary;
assert_eq!(actual, expected);
let code_str = "0x4f";
let actual: Code = code_str.parse()?;
let expected = Code::QNX4Tertiary;
assert_eq!(actual, expected);
let code_str = "0x50";
let actual: Code = code_str.parse()?;
let expected = Code::OnTrackDM;
assert_eq!(actual, expected);
let code_str = "0x51";
let actual: Code = code_str.parse()?;
let expected = Code::OnTrackDM6Aux1;
assert_eq!(actual, expected);
let code_str = "0x52";
let actual: Code = code_str.parse()?;
let expected = Code::CPM80;
assert_eq!(actual, expected);
let code_str = "0x53";
let actual: Code = code_str.parse()?;
let expected = Code::OnTrackDM6Aux3;
assert_eq!(actual, expected);
let code_str = "0x54";
let actual: Code = code_str.parse()?;
let expected = Code::OnTrackDM6Ddo;
assert_eq!(actual, expected);
let code_str = "0x55";
let actual: Code = code_str.parse()?;
let expected = Code::EZDrive;
assert_eq!(actual, expected);
let code_str = "0x56";
let actual: Code = code_str.parse()?;
let expected = Code::GoldenBow;
assert_eq!(actual, expected);
let code_str = "0x5c";
let actual: Code = code_str.parse()?;
let expected = Code::PriamEDisk;
assert_eq!(actual, expected);
let code_str = "0x61";
let actual: Code = code_str.parse()?;
let expected = Code::SpeedStor;
assert_eq!(actual, expected);
let code_str = "0x63";
let actual: Code = code_str.parse()?;
let expected = Code::GNUHurdSystemV;
assert_eq!(actual, expected);
let code_str = "0x64";
let actual: Code = code_str.parse()?;
let expected = Code::NovellNetware286;
assert_eq!(actual, expected);
let code_str = "0x65";
let actual: Code = code_str.parse()?;
let expected = Code::NovellNetware386;
assert_eq!(actual, expected);
let code_str = "0x70";
let actual: Code = code_str.parse()?;
let expected = Code::DiskSecureMultiBoot;
assert_eq!(actual, expected);
let code_str = "0x75";
let actual: Code = code_str.parse()?;
let expected = Code::PCIX;
assert_eq!(actual, expected);
let code_str = "0x80";
let actual: Code = code_str.parse()?;
let expected = Code::OldMinix;
assert_eq!(actual, expected);
let code_str = "0x81";
let actual: Code = code_str.parse()?;
let expected = Code::MinixOldLinux;
assert_eq!(actual, expected);
let code_str = "0x82";
let actual: Code = code_str.parse()?;
let expected = Code::LinuxSwap;
assert_eq!(actual, expected);
let code_str = "0x83";
let actual: Code = code_str.parse()?;
let expected = Code::Linux;
assert_eq!(actual, expected);
let code_str = "0x84";
let actual: Code = code_str.parse()?;
let expected = Code::OS2HiddenCDrive;
assert_eq!(actual, expected);
let code_str = "0x85";
let actual: Code = code_str.parse()?;
let expected = Code::LinuxExtended;
assert_eq!(actual, expected);
let code_str = "0x86";
let actual: Code = code_str.parse()?;
let expected = Code::FAT16VolumeSet;
assert_eq!(actual, expected);
let code_str = "0x87";
let actual: Code = code_str.parse()?;
let expected = Code::NTFSVolumeSet;
assert_eq!(actual, expected);
let code_str = "0x88";
let actual: Code = code_str.parse()?;
let expected = Code::LinuxPlaintext;
assert_eq!(actual, expected);
let code_str = "0x8e";
let actual: Code = code_str.parse()?;
let expected = Code::LinuxLVM;
assert_eq!(actual, expected);
let code_str = "0x93";
let actual: Code = code_str.parse()?;
let expected = Code::Amoeba;
assert_eq!(actual, expected);
let code_str = "0x94";
let actual: Code = code_str.parse()?;
let expected = Code::AmoebaBadBlockTable;
assert_eq!(actual, expected);
let code_str = "0x9f";
let actual: Code = code_str.parse()?;
let expected = Code::BSDOs;
assert_eq!(actual, expected);
let code_str = "0xa0";
let actual: Code = code_str.parse()?;
let expected = Code::IBMThinkpad;
assert_eq!(actual, expected);
let code_str = "0xa5";
let actual: Code = code_str.parse()?;
let expected = Code::FreeBSD;
assert_eq!(actual, expected);
let code_str = "0xa6";
let actual: Code = code_str.parse()?;
let expected = Code::OpenBSD;
assert_eq!(actual, expected);
let code_str = "0xa7";
let actual: Code = code_str.parse()?;
let expected = Code::NextStep;
assert_eq!(actual, expected);
let code_str = "0xa8";
let actual: Code = code_str.parse()?;
let expected = Code::DarwinUFS;
assert_eq!(actual, expected);
let code_str = "0xa9";
let actual: Code = code_str.parse()?;
let expected = Code::NetBSD;
assert_eq!(actual, expected);
let code_str = "0xab";
let actual: Code = code_str.parse()?;
let expected = Code::DarwinBoot;
assert_eq!(actual, expected);
let code_str = "0xaf";
let actual: Code = code_str.parse()?;
let expected = Code::HFSHFSPlus;
assert_eq!(actual, expected);
let code_str = "0xb7";
let actual: Code = code_str.parse()?;
let expected = Code::BSDIFs;
assert_eq!(actual, expected);
let code_str = "0xb8";
let actual: Code = code_str.parse()?;
let expected = Code::BSDISwap;
assert_eq!(actual, expected);
let code_str = "0xbb";
let actual: Code = code_str.parse()?;
let expected = Code::BootWizardHidden;
assert_eq!(actual, expected);
let code_str = "0xbc";
let actual: Code = code_str.parse()?;
let expected = Code::AcronisFAT32LBA;
assert_eq!(actual, expected);
let code_str = "0xbe";
let actual: Code = code_str.parse()?;
let expected = Code::SolarisBoot;
assert_eq!(actual, expected);
let code_str = "0xbf";
let actual: Code = code_str.parse()?;
let expected = Code::Solaris;
assert_eq!(actual, expected);
let code_str = "0xc1";
let actual: Code = code_str.parse()?;
let expected = Code::DRDOSSecuredFAT12;
assert_eq!(actual, expected);
let code_str = "0xc4";
let actual: Code = code_str.parse()?;
let expected = Code::DRDOSSecuredFAT16;
assert_eq!(actual, expected);
let code_str = "0xc6";
let actual: Code = code_str.parse()?;
let expected = Code::DRDOSSecuredFAT16B;
assert_eq!(actual, expected);
let code_str = "0xc7";
let actual: Code = code_str.parse()?;
let expected = Code::Syrinx;
assert_eq!(actual, expected);
let code_str = "0xda";
let actual: Code = code_str.parse()?;
let expected = Code::NonFsData;
assert_eq!(actual, expected);
let code_str = "0xdb";
let actual: Code = code_str.parse()?;
let expected = Code::CPMCtOs;
assert_eq!(actual, expected);
let code_str = "0xde";
let actual: Code = code_str.parse()?;
let expected = Code::DellUtilityFAT16;
assert_eq!(actual, expected);
let code_str = "0xdf";
let actual: Code = code_str.parse()?;
let expected = Code::BootIt;
assert_eq!(actual, expected);
let code_str = "0xe1";
let actual: Code = code_str.parse()?;
let expected = Code::DOSAccess;
assert_eq!(actual, expected);
let code_str = "0xe3";
let actual: Code = code_str.parse()?;
let expected = Code::DOSRO;
assert_eq!(actual, expected);
let code_str = "0xe4";
let actual: Code = code_str.parse()?;
let expected = Code::SpeedStorFAT16;
assert_eq!(actual, expected);
let code_str = "0xea";
let actual: Code = code_str.parse()?;
let expected = Code::FreedesktopBoot;
assert_eq!(actual, expected);
let code_str = "0xeb";
let actual: Code = code_str.parse()?;
let expected = Code::BeOSBFS;
assert_eq!(actual, expected);
let code_str = "0xee";
let actual: Code = code_str.parse()?;
let expected = Code::GPTProtectiveMBR;
assert_eq!(actual, expected);
let code_str = "0xef";
let actual: Code = code_str.parse()?;
let expected = Code::EfiSystem;
assert_eq!(actual, expected);
let code_str = "0xf0";
let actual: Code = code_str.parse()?;
let expected = Code::PARISCLinux;
assert_eq!(actual, expected);
let code_str = "0xf1";
let actual: Code = code_str.parse()?;
let expected = Code::SDSpeedstor;
assert_eq!(actual, expected);
let code_str = "0xf4";
let actual: Code = code_str.parse()?;
let expected = Code::SpeedStorFAT16B;
assert_eq!(actual, expected);
let code_str = "0xf2";
let actual: Code = code_str.parse()?;
let expected = Code::DOSSecondary;
assert_eq!(actual, expected);
let code_str = "0xf8";
let actual: Code = code_str.parse()?;
let expected = Code::EBBRProtective;
assert_eq!(actual, expected);
let code_str = "0xfb";
let actual: Code = code_str.parse()?;
let expected = Code::VMWareVMFS;
assert_eq!(actual, expected);
let code_str = "0xfc";
let actual: Code = code_str.parse()?;
let expected = Code::VMWareVMKCORE;
assert_eq!(actual, expected);
let code_str = "0xfd";
let actual: Code = code_str.parse()?;
let expected = Code::LinuxRaidAuto;
assert_eq!(actual, expected);
let code_str = "0xfe";
let actual: Code = code_str.parse()?;
let expected = Code::LanStep;
assert_eq!(actual, expected);
let code_str = "0xff";
let actual: Code = code_str.parse()?;
let expected = Code::XenixBadBlockTable;
assert_eq!(actual, expected);
Ok(())
}
}