zip_framing/host.rs
1use crate::wire::wire_enum;
2
3wire_enum! {
4 /// The host-system interpretation of a ZIP member's external attributes.
5 ///
6 /// This is the high byte of "version made by" (APPNOTE section 4.4.2).
7 /// It identifies attribute compatibility, not necessarily the writer's OS.
8 /// Conversions to and from [`u8`] preserve unrecognized identifiers.
9 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
10 #[non_exhaustive]
11 pub enum HostSystem(u8) {
12 /// MS-DOS and OS/2 FAT, VFAT, and FAT32 filesystems.
13 MsDos = 0,
14 /// Amiga.
15 Amiga = 1,
16 /// OpenVMS.
17 OpenVms = 2,
18 /// UNIX.
19 Unix = 3,
20 /// VM/CMS.
21 VmCms = 4,
22 /// Atari ST.
23 AtariSt = 5,
24 /// OS/2 HPFS.
25 Os2Hpfs = 6,
26 /// Macintosh.
27 Macintosh = 7,
28 /// Z-System.
29 ZSystem = 8,
30 /// CP/M.
31 Cpm = 9,
32 /// Windows NTFS.
33 WindowsNtfs = 10,
34 /// MVS, OS/390, and z/OS.
35 Mvs = 11,
36 /// VSE.
37 Vse = 12,
38 /// Acorn RISC.
39 AcornRisc = 13,
40 /// VFAT.
41 Vfat = 14,
42 /// Alternate MVS.
43 AlternateMvs = 15,
44 /// BeOS.
45 BeOs = 16,
46 /// Tandem.
47 Tandem = 17,
48 /// OS/400.
49 Os400 = 18,
50 /// OS X (Darwin).
51 Darwin = 19,
52 }
53}
54
55#[cfg(test)]
56mod tests {
57 use super::HostSystem;
58
59 #[test]
60 fn preserves_host_identifiers() {
61 for value in u8::MIN..=u8::MAX {
62 let host = HostSystem::from(value);
63 if value >= 20 {
64 assert_eq!(host, HostSystem::Unknown(value));
65 }
66 assert_eq!(u8::from(host), value);
67 }
68 }
69}