#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[allow(clippy::upper_case_acronyms)]
#[repr(u8)]
pub enum System {
Dos = 0,
Amiga = 1,
OpenVMS = 2,
Unix = 3,
VmCms = 4,
AtariSt = 5,
Os2 = 6,
Macintosh = 7,
ZSystem = 8,
CPM = 9,
WindowsNTFS = 10,
MVS = 11,
VSE = 12,
AcornRisc = 13,
VFAT = 14,
AlternateMVS = 15,
BeOS = 16,
Tandem = 17,
Os400 = 18,
OsDarwin = 19,
#[default]
Unknown = 255,
}
impl System {
#[must_use]
pub fn from_version_made_by(version_made_by: u16) -> Self {
let upper_byte = version_made_by.to_le_bytes()[1];
System::from(upper_byte) }
pub(crate) fn extract_bytes(version_made_by: u16) -> (u8, Self) {
let bytes = version_made_by.to_le_bytes();
(bytes[0], Self::from(bytes[1]))
}
}
impl From<u8> for System {
fn from(system: u8) -> Self {
match system {
0 => System::Dos,
1 => System::Amiga,
2 => System::OpenVMS,
3 => System::Unix,
4 => System::VmCms,
5 => System::AtariSt,
6 => System::Os2,
7 => System::Macintosh,
8 => System::ZSystem,
9 => System::CPM,
10 => System::WindowsNTFS,
11 => System::MVS,
12 => System::VSE,
13 => System::AcornRisc,
14 => System::VFAT,
15 => System::AlternateMVS,
16 => System::BeOS,
17 => System::Tandem,
18 => System::Os400,
19 => System::OsDarwin,
_ => System::Unknown,
}
}
}
impl From<System> for u8 {
fn from(system: System) -> Self {
system as u8
}
}
#[rustfmt::skip]
#[repr(u16)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub(crate) enum ZipFlags {
Encrypted = 0b0000_0000_0000_0001,
#[allow(unused)]
CompressionSetting = 0b0000_0000_0000_0010,
#[allow(unused)]
CompressionSetting2 = 0b0000_0000_0000_0100,
UsingDataDescriptor = 0b0000_0000_0000_1000,
#[allow(unused)]
ReservedEnhancedDeflating = 0b0000_0000_0001_0000,
#[allow(unused)]
CompressedPatchedData = 0b0000_0000_0010_0000,
#[allow(unused)]
StrongEncryption = 0b0000_0000_0100_0000,
LanguageEncoding = 0b0000_1000_0000_0000,
#[allow(unused)]
ReservedEnhancedCompression = 0b0001_0000_0000_0000,
#[allow(unused)]
Masked = 0b0010_0000_0000_0000,
#[allow(unused)]
ReservedAlternateStream = 0b0100_0000_0000_0000,
#[allow(unused)]
Reserved = 0b1000_0000_0000_0000,
}
impl ZipFlags {
pub(crate) fn matching(flags: u16, matching_flag: Self) -> bool {
flags & u16::from(matching_flag) != 0
}
pub(crate) const fn as_u16(self) -> u16 {
self as u16
}
}
impl From<ZipFlags> for u16 {
fn from(value: ZipFlags) -> u16 {
value.as_u16()
}
}